MySQL5.7.13更改密码时出现ERROR 1054 (42S22): Unknown column 'password' in 'field list'

来源:互联网 发布:linux怎样启动tomcat 编辑:程序博客网 时间:2024/05/29 13:12

记录一下这个坑,MySQL5.7.13更改密码时出现ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’。

windows下使用免安装版本的mysql5.7.13,各种需要自己配置。步骤如下(使用cmd最好在管理员权限下):

1.首先在环境变量中配置path:D:\Program Files\MySQL\MySQL Server 5.7\bin; (自己的安装目录下的bin目录)

2.改掉安装目录的my-default.ini名称为my.ini

3.修改my.ini如下

[mysqld]# Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. innodb_buffer_pool_size = 128M# Remove leading # to turn on a very important data integrity option: logging# changes to the binary log between backups.# log_bin# These are commonly set, remove the # and set as required. basedir = "D:\Program Files\MySQL\MySQL Server 5.7" datadir = "D:\Program Files\MySQL\MySQL Server 5.7\data" port = 3306 server_id = 1 character_set_server = utf8# Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values. join_buffer_size = 128M sort_buffer_size = 2M read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

上面的目录请参考自己的安装目录。

4.在cmd下使用命令 mysqld - -initialize 初始化data目录
(两个短杆连在一起,为了看清把他们分开了)

5.在cmd下使用命令 mysqld - -install mysql 来创建mysql服务
(需要卸载服务使用mysqld - -remove mysql,两个短杆连在一起)

6.服务开启后,在cmd下输入mysql,会报错ERROR 1045 (28000): Access denied for user ‘toot’@’localhost’ (using password: NO);
输入mysql -uroot -p后会提示输入密码,这时输入密码也不正确,报错ERROR 1045 (28000): Access denied for user ‘toot’@’localhost’ (using password: YES)。只能想着改密码了。

下面是改密码的步骤:

7.在my.ini文件中添加一句skip-grant-tables,去掉安全检查

8.直接下cmd下输入mysql进入mysql>; 在mysql>下输入 UPDATE mysql.user set password=PASSWORD(’newpassword’) WHERE User=’root’; 进行密码更改。
在mysql5.7.13这个版本更改密码时出现ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’错误,原来password字段被改为authentication_string了。第8步出错则走第9步;

9.在mysql>下使用update mysql.user set authentication_string=password(‘root’) where user=’root’ ; (注意单引号为英文状态下的)

10.此时用设置的密码root就可以进入了mysql>,当输入诸如select now(); 可能会出现提示ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. 此时继续使用SET PASSWORD = PASSWORD(‘newpsd’); 进行新密码的设置。

11.使用新密码登陆,就可以执行相关操作了。
登录成功如下:

C:\WINDOWS\system32>mysql -uroot -pEnter password: ****Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.7.13 MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

12.最后,在my.ini文件中将第8步添加的skip-grant-tables这一行去掉

注意事项

  1. 使用cmd最好在管理员状态下(右键以管理员运行)
  2. 命令中的字符都是在英文状态下输入的
  3. 关于某些目录请参考自己的安装目录来对应

有资源怎么能不共享呢,mysql5.7.13需要的自取传送门


后记,真是自己一手配置不易啊~。尤其某些地方有点坑。最后自己把这个过程记录了下来,希望给有同样问题的你一点帮助~。

0 0