- 第一步:查看密码
root@evo:sudo cat /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = cfhuKqdMEd8ozBb2
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = cfhuKqdMEd8ozBb2
socket = /var/run/mysqld/mysqld.sock
- 第二步:进入数据库修改密码
root@evo: mysql -u debian-sys-maint -p
Enter password:
mysql> use mysql;
mysql> update mysql.user set authentication_string=password('123456') where user='root' and Host ='localhost';
mysql> update user set plugin="mysql_native_password";
mysql> flush privileges;
- 第三步:修改远程访问
mysql> grant all on *.* to 'root'@'%' identified by '123456';
mysql> flush privileges;
mysql> quit
- 第四步:重启数据库
root@evo: service mysql restart