mysql出现 Unknown column 'Password' in 'field list'
linux安装了mysql之后初始化密码获取:出现了下面的内容,密码很尴尬,无法用root登录:
1 grep 'temporary password' /var/log/mysqld.log
1 | [Note] A temporary password is generated for root@localhost: 4)ZqW0IooQ(a |
出错如下:
1 2 | [root@iZuf655czz7lmtn8v15tsjZ mysql] # mysql -uroot -p 4)ZqW0IooQ(a - bash : syntax error near unexpected token `)' |
百度一番找到直接修改登录方式,无密码登录,修改密码:
1、执行以下命令
1 | vi /etc/my .cnf |
2、找[mysqld],在下面添加如下内容:
1 2 | [mysqld] skip-grant-tables |
3、重启mysql:
1 | service mysqld restart |
4、无密码登录mysql
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | [root@iZuf655czz7lmtn8v15tsjZ mysql] # mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.28 MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and /or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and /or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> |
5、执行以下命令,本以为顺风顺水,然鹅。。。
1 | update mysql.user set Password=PASSWORD( '123456' ) where USER= 'root' ; |
。。。
1 | ERROR 1054 (42S22): Unknown column 'Password' in 'field list' |
6、看下这个 mysql.user 表里是些啥。。。
1 | select * from mysql.user; |
看来看去就这个列名顺眼:
于是我改了下语句:
1 2 3 | mysql> update mysql.user set authentication_string=PASSWORD( '123456' ) where USER= 'root' ; Query OK, 1 row affected, 1 warning (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 1 |
。。。wtf(原来,mysql5.7更改密码应该采用命令ALTER USER
'root'
@
'localhost'
IDENTIFIED BY
'********'其中密码的命名规则有所改变:
MySQL 设置的密码中必须至少包含一个大写字母、一个小写字母、一个特殊符号、一个数字,密码长度至少为8位)
7、好在改完了,接下来执行回退,回到/etc/my.cnf中删除新增的skip-grant-tables重启即可
分享即成长
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现