1.打开MySQL配置文件 my.ini中,添加上skip-grant-tables,可以添加到文件的末尾或者是这添加到[mysqld]的下面。
2.重启mysql
3.这时登录MySQL不再需要验证
切换到mysql系统库:
mysql> use mysql;
修改root账户登录密码:
mysql> update user set password=password('') where user='root';
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
---报错没有password这个数据字段列
描述user表
mysql> desc user;
...
| authentication_string | text | YES | | NULL | |
| password_expired | enum('N','Y') | NO | | N | |
| password_last_changed | timestamp | YES | | NULL | |
| password_lifetime | smallint(5) unsigned | YES | | NULL | |
| account_locked | enum('N','Y') | NO | | N | |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
---没发现password列,但是找到这5个跟密码相关的数据字段
查询一下相关的密码信息:
mysql> select user,host,authentication_string,password_expired from user;
+-----------+-----------+-------------------------------------------+------------------+
| user | host | authentication_string | password_expired |
+-----------+-----------+-------------------------------------------+------------------+
| root | localhost | *9AA01F6E2A80A823ACB72CC07337E2911404B5B8 | Y |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | N |
+-----------+-----------+-------------------------------------------+------------------+
---到这里不难发现root账户的密码已过期,还比5.6多出了一个mysql.sys用户
修改密码
mysql> update user set authentication_string=password('123abc') where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit