20200116_centos7.2 下 mysql_5.7修改root密碼


1. 需改my.cnf文件

[root@rakinda-iot-platform ~]# vim /etc/my.cnf

2. 新增一行, 登錄時跳過密碼, 保存后退出, 重啟mysql  

systemctl restart mysqld

skip-grant-tables

3. 直接使用mysql登入到數據庫:

 

 4. 輸入update 修改密碼:

mysql> update user set password=password('yourpassword') where user='root';
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
#5.7下面已經不支持password字段了, 可以使用select查看一下user表的確沒有password字段了
mysql> select *from user \G

5. 所以使用下面的語句, 修改authentication_string字段:

mysql> update user set authentication_string=password('yourpassword') where user='root';
Query OK, 2 rows affected, 1 warning (0.00 sec)
Rows matched: 2  Changed: 2  Warnings: 1

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit;

6. 別忘了把配置文件的skip-grant-tables 去掉


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM