四步解决Ubuntu下忘记MySQL root密码问题
1) 编辑mysql的配置文件/etc/mysql/my.cnf,在[mysqld]段下加入一行“skip-grant-tables”;
2) 重启mysql服务(执行 service mysql restart);
3) 进入mysql对其进行设置密码;
进入mysql (use mysql )后执行update user set password=PASSWORD(“new_pass”) where user=’root’;密码修改为new_pass
(详情看后面代码)
4) 删除 步骤1 增加的那行后,重启mysql(同2);
@ubuntu:~$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
……
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql
……
mysql> update user set password=PASSWORD("new_pass") where user='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 4 Changed: 0 Warnings: 0
mysql> exit
Bye
@ubuntu:~$
(全文完)
(欢迎转载本站文章,但请注明作者和出处 云域 – Yuccn )