歡迎關注MySQL 8.0必知必會系列課程。
MySQL8.0必知必會-自動化部署 https://edu.51cto.com/course/16368.html
MySQL8.0必知必會之參數標準化配置 https://edu.51cto.com/course/16358.html
1.關閉數據庫實例
ps -ef|grep mysqld
kill -9 pid
2.不加載權限表方式啓動
--skip-grant-tables 不加載權限表
mysql 8.0在使用--skip-grant-tables時,會自動啓動選項--skip-networking來禁止遠程連接。
mysqld --defaults-file=/mysqldb/db_ark/conf/ark.cnf --skip-grant-tables
3.root用戶登錄
mysql -uroot -S /mysqldb/db_ark/mysql.sock
賬號需要具備alter、reload權限
4.加載權限表
flush privileges;
5.修改密碼
alter user root@localhost identified by 'mysql';
flush privileges;
6.正常啓動mysql服務
ps -ef|grep mysqld
kill –9 pid
nohup mysqld_safe --defaults-file=/mysqldb/db_ark/conf/ark.cnf &
7.測試新密碼
mysql -uroot -pmysql -S /mysqldb/db_ark/mysql.sock
總結:
1. mysql 8.0修改權限時,需要加載權限表
2. 無法找回舊密碼,只能重置