1.在root用戶下,停止mysql
service mysqld stop
2.vi /etc/my.cnf
在[mysqld]的段中加上一句skip-grant-tables
[mysqld]
skip-grant-tables
shift+z+z;保存退出
3.重新啟動mysql
systemctl start mysqld
3.登錄修改mysql 的密碼
[root@python2 hadoop]# mysql -uroot -p
Enter password:
一直敲回車
Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 2
Server version: 5.7.21 MySQL Community Server (GPL)
看到welcome登錄成功
5.FLUSH PRIVILEGES; 執行這條命令刷新
6.授權
mysql> GRANT ALL PRIVILEGES ON . TO ‘myuser’@’%'IDENTIFIED BY ‘mypassword’ WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.01 sec)
6:修改密碼
mysql> ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘123456’;
Query OK, 0 rows affected (0.00 sec)
7.退出 quit;
到vi /etc/my.cnf 刪除skip-grant-tables7.登錄mysql 成功修改密碼並登錄 ———————————————— 版權聲明:本文為CSDN博主「baiyan_er」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。 原文鏈接:https://blog.csdn.net/baiyan_er/article/details/79966217