今天重装了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