今天重裝了mysql,裝好後,並無設置密碼。如今須要設置下密碼
1.cmd
2.指定用戶登陸mysql,以下我指定root用戶mysql
C:\Users\Administrator>mysql -u root -p
3.輸入登陸密碼sql
Enter password:
備註:因爲我是新裝mysql,並無設置密碼,因此這裏直接回車便可。
4.歡迎頁面加密
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 5.7.14 MySQL Community Server (GPL)
5.修改/設置密碼code
mysql> set password for root@localhost=password('654321'); Query OK, 0 rows affected, 1 warning (0.00 sec)
備註:下面很明顯提示修改爲功
6.查看錶中帳號和密碼cmd
mysql> select user,authentication_string from mysql.user; +-----------+-------------------------------------------+ | user | authentication_string | +-----------+-------------------------------------------+ | root | *2A032F7C5BA932872F0F045E0CF6B53CF702F2C5 | | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | +-----------+-------------------------------------------+ 2 rows in set (0.00 sec)
備註:由上可知:mysql5.7以後沒有password這個列了,修改爲了"authentication_string"。同時,可知root的密碼是加密了(咱們設置的原密碼"654321")。string