自從mysql5.7版本開始不支持在安裝時(shí)手動(dòng)設(shè)置密碼阱驾,所以要在安裝mysql后手動(dòng)設(shè)置root的用戶的密碼和密碼登錄衙伶。
查找數(shù)據(jù)庫(kù)root原始密碼:
sudo cat /etc/mysql/debian.cnf
登錄:
mysql -u debian-sys-maint -p
use mysql;
update mysql.user set authentication_string =password('admin123') where user='root' and Host='localhost';
update user set plugin='mysql_native_password' where User='root';
flush privileges;
quit;
重啟mysql
sudo systemctl restart mysql