怎么解决MySQL忘记root密码
程序员文章站
2022-06-12 20:58:37
...
如何解决MySQL忘记root密码 要修改MySQL的root密码,有两个先决条件:? 有修改MySQL配置文件的权限 有重启MySQL服务的权限 先修改配置文件:? 引用 # vim /etc/my.cnf? [mysqld]? datadir=/var/lib/mysql? socket=/var/lib/mysql/mysql.sock? user=mysql? # D
如何解决MySQL忘记root密码要修改MySQL的root密码,有两个先决条件:?
- 有修改MySQL配置文件的权限
- 有重启MySQL服务的权限
先修改配置文件:?
# vim /etc/my.cnf?
[mysqld]?
datadir=/var/lib/mysql?
socket=/var/lib/mysql/mysql.sock?
user=mysql?
# Default to using old password format for compatibility with mysql 3.x?
# clients (those using the mysqlclient10 compatibility package).?
old_passwords=1?
# Disabling symbolic-links is recommended to prevent assorted security risks;?
# to do so, uncomment this line:?
# symbolic-links=0?
[mysqld_safe]?
log-error=/var/log/mysqld.log?
pid-file=/var/run/mysqld/mysqld.pid
在[mysqld]下增加skip-grant-tables,即跳过权限验证。?
然后登录MySQL,修改root密码:?
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> update user SET Password = password('
Query OK, 3 rows affected (0.00 sec)?
Rows matched: 3? Changed: 3? Warnings: 0?
mysql> flush privileges ;?
Query OK, 0 rows affected (0.00 sec)?
mysql> quit?
Bye?
然后把刚才修改的配置文件再改回来,最后重启服务:?
# service mysqld restart?
停止 MySQL:?????????????????????????????????????????????? [确定]?
启动 MySQL:?????????????????????????????????????????????? [确定]?
呵呵,解决Mysql忘记密码就这么简单。
PS:更果断的办法:?
关闭mysqld?
命令行执行 mysqld --skip-grant-tables & 无密码登陆!?
?
下一篇: 请问回调函数有关问题
推荐阅读
-
MySQL5.7如何修改root密码
-
linux mysql忘记密码的多种解决或Access denied for user 'root'@'localhost'
-
12306密码泄露怎么办?12306密码外泄解决方法
-
Win7系统bitlocker磁盘密码忘记了的解决方法
-
经测试最好用的mysql密码忘记的解决方法
-
怎么破解开机密码适合忘记不知道密码的情况
-
Linux忘记root密码的解决办法(图文)
-
MySql8.0以上版本正确修改ROOT密码的方法
-
Mysql5.7忘记root密码怎么办(简单且有效方法)
-
新装MySql后登录出现root帐号提示mysql ERROR 1045 (28000): Access denied for use的解决办法