Ubuntu server 安装的mysql数据库忘记密码的解决方法
客户端连接时报错MySQL数据库出现:Error 1045错误时,就表明输入的用户名或密码错误被拒绝访问了。
解决办法可以分为以下几步:
1.修改mysql配置文件,使得可以无密码登录mysql
sudo vim /etc/mysql/my.cnf
在[mysqld]项下添加
skip-grant-tables
2.重启mysql服务
sudo service mysql restart
3.无密码登录mysql
mysql -uroot -p
4.修改管理员密码
use mysql;
update user set password=password('123') where user='root';
flush privileges;
exit;
5.还原配置文件
6.可以使用下面的命令登录
mysql -uroot -p123
2003 - Can't connect to MySQL server on 'x.x.x.x' (10038)
mysql服务没问题:
- sean@sean:~$ ps -ef|grep mysqld
- mysql 1219 1 0 21:09 ? 00:00:01 /usr/sbin/mysqld
- sean 10373 9602 0 21:38 pts/7 00:00:00 grep --color=auto mysqld
并且本地的登录也能成功:
- sean@sean:~$ mysql -u root -h 127.0.0.1
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 40
- Server version: 5.5.47-0ubuntu0.14.04.1 (Ubuntu)
- Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- mysql>
但是使用外网地址却无法登录:
- sean@sean:~$ mysql -u root -h 192.168.137.128
- ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.137.128' (111)
于是修改了一下MySQL的配置文件:
- sean@sean:~$ sudo vi /etc/mysql/my.cnf
在bind-address= 127.0.0.1这一行前加#(注释掉这行)
- # Instead of skip-networking the default is now to listen only on
- # localhost which is more compatible and is not less secure.
- #bind-address = 127.0.0.1
然后重启mysql服务:
- sean@sean:~$ sudo service mysql restart
- mysql stop/waiting
- mysql start/running, process 11622
ERROR 1130: mysql 1130连接错误的有效解決方法
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
mysql> select host, user, password from user;
+-----------+------------------+-------------------------------------------+
| host | user | password |
+-----------+------------------+-------------------------------------------+
| localhost | root | |
| sean | root | |
| 127.0.0.1 | root | |
| ::1 | root | |
| localhost | debian-sys-maint | *0AA379AB8AFD785B32D661A07E9D5C7A24E3B186 |
+-----------+------------------+-------------------------------------------+
5 rows in set (0.00 sec) mysql> update user set host = "%" where host = "sean" and user = "root";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec) mysql> select host, user, password from user;
+-----------+------------------+-------------------------------------------+
| host | user | password |
+-----------+------------------+-------------------------------------------+
| localhost | root | |
| % | root | |
| 127.0.0.1 | root | |
| ::1 | root | |
| localhost | debian-sys-maint | *0AA379AB8AFD785B32D661A07E9D5C7A24E3B186 |
+-----------+------------------+-------------------------------------------+
5 rows in set (0.00 sec)
使用Navicat就可以成功连接至数据库了.
Ubuntu server 安装的mysql数据库忘记密码的解决方法的更多相关文章
- Mysql数据库忘记密码找回方法
Mysql数据库忘记密码找回 a 停止mysql服务 /etc/init.d/mysql stop b 使用--skip-grant-tables启动mysql,忽略授权登录验证 mysqld_saf ...
- mysql数据库忘记密码时如何修改(一)
方法/步骤 打开mysql.exe和mysqld.exe所在的文件夹,复制路径地址 打开cmd命令提示符,进入上一步mysql.exe所在的文件夹. 输入命令 mysqld --skip-grant ...
- Windows下mysql忘记密码的解决方法
Windows下mysql忘记密码的解决方法 mysql5.0 http://www.jb51.net/article/21984.htm方法一: 1.在DOS窗口下输入 net stop mysql ...
- Centos下忘记mysql的root密码的解决方法
Centos下忘记mysql的root密码的解决方法 一:(停掉正在运行的mysql) [root@NetDakVPS ~]# service mysql stop 二:使用 “--skip-gran ...
- Mac下新安装的MySQL无法登陆root用户解决方法
一 设置MySQL命令行搜索路径 0.苹果->系统偏好设置->最下边点mysql 在弹出页面中 启动mysql服务 1.打开终端,输入: sudo vi ~/.bash_profile ...
- mysql8忘记密码的解决方法
mysql8忘记密码的解决方法 1.管理员身份打开cmd,进入dos 2.停止mysql服务 命令:net stop mysql 3.无密码启动 命令:mysqld --console --skip- ...
- Windows2008系统忘记密码的解决方法
网上转载的,忘记密码不用发愁了. windows2008系统忘记密码的解决方法: 利用放大镜的漏洞来重设密码 首先用系统盘来引导 选择修复计算机 然后打开命令提示符:先备份放大镜,然后用CMD替换 ...
- MySQL数据库忘记密码怎么办?
忘记MySQL数据库密码就进不去数据库,也就无法修改密码,解决方法如下: 1:打开cmd命令符,先关闭正在运行的数据库,输入如下命令: 2:打开mysql.exe和mysqld.exe所在的文件夹,复 ...
- 忘记mysql超户密码的解决方法
本文章针对用yum安装的mariadb数据库,如果是tar包安装的mysql数据库,只是数据库命令的关闭启动方式不同而已. 方法一:[root@localhost ~]# killall -u mys ...
随机推荐
- ios开发之--CGRect/CGSize/CGPoint/CGVector/CGAffineTransform/UIEdgeInsets/UIOffset和NSString之间的转换
仅做记录,一个函数和字符串之间的互相转换 方法如下: UIKIT_EXTERN NSString *NSStringFromCGPoint(CGPoint point); UIKIT_EXTERN N ...
- sed使用
sed命令 一.替换标记 s/pattern/replacement/flags 默认情况下只会替换每行的首次出现的内容,如果要替换其他位置需要使用flags 1.不使用flag [root@bogo ...
- linux如何查看某个pid的进程?
Linux通过PID查看进程完整信息 [root@gsidc-4q-saas23 ~]# netstat -anp|grep 8282tcp 0 0 :::8282 :::* LISTEN 16923 ...
- ubuntu 卸载 google-chrome
sudo apt-get autoremove google-chrome-stable
- Caused by: java.sql.SQLException: Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1@d7c365, see the next exception for details.
解决方法:https://stackoverflow.com/questions/37442910/spark-shell-startup-errors 异常: 18/01/29 19:04:27 W ...
- webPage logService 日志服务 剥离
[旧的场景]1.x.a.com指向负载均衡服务器ipL;2.代码所在的应用服务器ipA,ipB,ipC,运行nginx-phpFPM服务,提供2个服务: 2.1.应用服务器ipA,ipB,ipC中we ...
- Apache2.4部署python3.6+django2.0项目
一.安装apache Apache是非常有名的web服务器软件,如果想让我们web项目运行几乎离不开它. Apache官方网站:http://httpd.apache.org/ 根据自己的环境,选择相 ...
- mysql 迁移数据
一.导出导入所有数据库的数据 1.导出 mysqldump -u root -p123456 --all-databases > all.sql 2.导入 mysql -u root -p123 ...
- Hadoop 入门教程
Hadoop 入门教程 https://blog.csdn.net/kkkloveyou/article/details/52348883
- pytorch中的cat、stack、tranpose、permute、unsqeeze
Cat 对数据沿着某一维度进行拼接.cat后数据的总维数不变. 比如下面代码对两个2维tensor(分别为2*3,1*3)进行拼接,拼接完后变为3*3还是2维的tensor. import torch ...