今天重装了mysql,装好后,并没有设置密码。现在需要设置下密码
1.cmd 2.指定用户登录mysql,如下我指定root用户C:\Users\Administrator>mysql -u root -p
3.输入登录密码
Enter password:
备注:由于我是新装mysql,并没有设置密码,所以这里直接回车即可。
4.欢迎页面Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 11Server version: 5.7.14 MySQL Community Server (GPL)
5.修改/设置密码
mysql> set password for root@localhost=password('654321');Query OK, 0 rows affected, 1 warning (0.00 sec)
备注:下面很明显提示修改成功
6.查看表中账号和密码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")。