ubuntu修改mysql密码的方法:
1、在终端中结束mysql进程。
# sudo /etc/init.d/mysql stop
2.用mysql安全模式运行并跳过权限验证。
# sudo /usr/bin/mysqld_safe --skip-grant-tables
3.重新打开一个终端页面以root身份登录mysql。
# mysql -u root
4.输入修改root用户口令,例如:
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> update user set Password = PASSWORD('root') where User ='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> exit
(注:括号里的'root'就是新密码。)
5.结束mysql安全模式,用正常模式运行mysql即可。
# sudo /etc/init.d/mysql restart
亿速云「云数据库 MySQL」免部署即开即用,比自行安装部署数据库高出1倍以上的性能,双节点冗余防止单节点故障,数据自动定期备份随时恢复。点击查看>>
推荐阅读:怎么在ubuntu中修改mysql密码