MySQL5.7更改密码时出现ERROR 1054 (42S22): Unknown column 'password' in 'fie
新安装的MySQL5.7,登录时提示密码错误,安装的时候并没有更改密码,后来通过免密码登录的方式更改密码,输入update mysql.user set password=password('root') where user='root'时提示ERROR 1054 (42S22): Unknown column 'password' in 'field list',原来是
mysql数据库下已经没有password这个字段了,password字段改成了
authentication_string
所以更改语句替换为update mysql.user set authentication_string=password('root') where user='root' ;即可
我的系统版本如下:
Centos 7.2 64位
完整的更改MySQL密码的方式如下:
1、vim /etc/my.cnf 加入skip-grant-tables
2、重启MySQL, /etc/init.d/mysqld restart
3、终端输入 mysql 直接登录MySQL数据库,然后use mysql
4、update mysql.user set authentication_string=password('root') where user='root' ;
5、编辑my.cnf文件删掉skip-grant-tables 这一行,然后重启MySQL,/etc/init.d/mysqld restart,否则MySQL仍能免密码登录
6、mysql -u root -p
然后输入密码即可登录MySQL数据库
安装mysql后,启动使用命令行登录之后,执行sql语句,提示错误:
1 | ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement |
解决:
设置mysql别称:
vim ~/.bash_profile
export mysql=/usr/local/mysql/bin/mysql
source ~/.bash_profile
1 | SET PASSWORD = PASSWORD( '新密码' ); |
1 | ALTER USER 'root' @ 'localhost' PASSWORD EXPIRE NEVER; |
1 | flush privileges; |