1.强制关闭MySQL# pkill mysql
2.向配置文件添加[mysqld]
skip-grant-tables
3.重启mysql 点击(此处)折叠或打开
![](/upload/ad_content/xuanchuantu-15.jpg)
成都创新互联是一家集网站建设,商水企业网站建设,商水品牌网站建设,网站定制,商水网站建设报价,网络营销,网络优化,商水网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。
-
# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &
-
[1] 29335
-
[root@mysql5 logs]# 180310 21:00:11 mysqld_safe Logging to '/home/mysql3306/logs/mysql-error.log'.
-
180310 21:00:11 mysqld_safe Starting mysqld daemon with databases from /home/mysql3306/mysql3306
4.无密码登录# /usr/local/mysql/bin/mysql -S /tmp/mysql.sock
5.重置root密码
-
mysql> update mysql.user set password=password('root') where user='root';
-
Query OK, 2 rows affected (0.03 sec)
-
Rows matched: 4 Changed: 2 Warnings: 0
-
-
mysql> flush privileges;
-
Query OK, 0 rows affected (0.02 sec)
6.重启mysql# pkill mysql
将skip-grant-tables从配置文件注销掉
# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &
7.验证# /usr/local/mysql/bin/mysql -S /tmp/mysql.sock -uroot -p
当前标题:mysql忘记root密码解决方法(linux)
转载注明:
http://cdkjz.cn/article/gigecd.html