MySQL 5.7不再彈出root密碼設(shè)置
sudo vi /etc/mysql/debian.cnf
顯示:
Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = fPw**********22
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password =fPw**********22
socket = /var/run/mysqld/mysqld.sock
找到了舔哪,用戶名:debian-sys-maint秉氧,密碼:fPw**********22(這是隨機(jī)生成的)
退出來渡嚣,Esc鍵,輸入“:q!”
mysql -u debian-sys-maint -p
Enter password:輸入剛才找到的密碼
接下來,設(shè)置root用戶密碼(假設(shè)為123456)
mysql> update mysql.user set authentication_string=PASSWORD(“123456″) where User=’root’;
更改root密碼芳来,然后出現(xiàn)
Query OK, 1 row affected, 1 warning (0.12 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> update mysql.user set plugin=”mysql_native_password”;
解決出現(xiàn)警告的問題,然后出現(xiàn)
Query OK, 1 row affected (0.02 sec)
Rows matched: 4 Changed: 1 Warnings: 0
mysql> flush privileges;
更新所有權(quán)限资溃,然后出現(xiàn)
Query OK, 0 rows affected (0.33 sec)
mysql> quit;
退出來烈炭,先關(guān)閉再啟動MySQL
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
用root用戶和密碼進(jìn)去看看
mysql -u root -p
Reference:http://tieba.baidu.com/p/5679939196