1. 程式人生 > >MySQL 重置 root 密碼 - 忘記密碼

MySQL 重置 root 密碼 - 忘記密碼

原文地址:https://renguangli.com/articles/mysql-reset-root-password

在配置檔案/etc/my.cnf新增配置,重啟mysql

##無密碼登入
skip-grant-tables;

客戶端連線mysql選擇mysql庫

mysql -uroot -p

修改root密碼5.7版本,5.7版本之後已經沒有了password欄位,而是用authentication_string加密欄位代替

update mysql.user set authentication_string=password('123qwe') where user='root';

5.7版本以前

update mysql.user set password=password('123qwe') where user='root';