1. 程式人生 > >MySQL 8.0為root用戶設置密碼

MySQL 8.0為root用戶設置密碼

flush ble 文件 alt root 密碼 mysq 登錄 pri

1、修改/etc/my.cnf文件
skip-grant-tables=1

2、登錄MySQL,並刷新
#mysql #登錄mysql
mysql>FLUSH PRIVILEGES;
3、修改root密碼,並刷新
mysql>ALTER USER ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘Password@123‘;
mysql>FLUSH PRIVILEGES;
4、設置遠程登錄並刷新
mysql>update user set host=‘%‘ where user=‘root‘;
mysql>FLUSH PRIVILEGES;

MySQL 8.0為root用戶設置密碼