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
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: ubuntu如何修改sources.list源