补充:总是疑惑为神魔有时候root无需密码也可登陆,偶然读到MySQL5.6和mysql5.7 的区别,5.7生成临时的密码后续必须该正,而5.6不需要密码直接登入
环境:
系统是红帽6.5,数据库用的
mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar
首先更改配置文件/etc/my.cnf加入一条:跳过密码 添加一条
skip-grant-tables
重启服务
[root@server6 ~]# /etc/init.d/mysqld restart
进入mysql库下面的user表,此表用于管理用户的帐号和密码
mysql> update user set password=password("Ting@2424") where user="root";
ERROR 1054 (42S22): Unknown column 'password' in 'field list'遇到报错,查询到是因为password字段不存在,变成了authentication_string,所以如果过不了的话用下面一条
mysql> update mysql.user set authentication_string=password('Ting@2424') where user='root' ;
Query OK, 1 row affected, 1 warning (0.16 sec)
Rows matched: 1 Changed: 1 Warnings: 1mysql> flush privileges;
Query OK, 0 rows affected (0.14 sec)mysql>exit
重启服务
按照重新设置的秘密即可 ok !哒哒哒