mysql数据库登录解决方法

本文介绍如何解决MySQL5.7登录时遇到的密码错误问题,并提供了详细的步骤来更新默认密码,包括修改配置文件、重启服务及使用SQL命令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = bFPCQUvTEzk9reOp
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = bFPCQUvTEzk9reOp
socket   = /var/run/mysqld/mysqld.sock

解决方法:
1.打开/etc/mysql/debian.cnf文件,里面存储了相关的密码,我的文件信息如下

sudovi /etc/mysql/debian.cnf# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = 6x1XG2B5p75WtFV2
socket = /var/run/mysqld/mysqld.sock

[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = 6x1XG2B5p75WtFV2
socket = /var/run/mysqld/mysqld.sock
basedir = /usr

在[client]段有user=以及password=这两行,这就是通过apt-get安装mysql,系统给我们设置的mysql登录名和密码

2. 输入命令:
mysql -udebian-sys-maint -pdebian-sys- maint即debian.cnf中user=后面的内容.回车后会提示输入密码,此时把password=后面的内容复制粘贴后回车即可进行mysql 控制台


3.进入控制台后.按以下步骤进行:
use mysql;update user set password=PASSWORD('新密码') where user='root';FLUSH PRIVILEGES;此时可以输入quit;退出后用root帐号登录,也可以继续其他操作.

MySQL5.7更改密码时出现ERROR 1054 (42S22): Unknown column 'password' in 'fie
[摘要:新装置的MySQL5.7,登录时提醒暗码毛病,装置的时间并出有变动暗码,厥后经过免暗码登录的体式格局变动暗码,输进update mysql.user set password=password('root') where user] 

新安装的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' ;即可


我的系统版本如下:


\

完整的更改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数据库
 

转载于:https://my.oschina.net/u/3264690/blog/884124

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值