Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
今天重新安装了15.10系统后,发现mysql无法登录了
Experiences and Insight
646
views ·
4
replies ·
To
floor
Go
王猛龙
deepin
2019-05-12 18:17
Author
本帖最后由 crownclown 于 2019-6-17 10:33 编辑
直接使用 apt 安装
$ sudo apt install mysql-server
Copy the Code
如果安装过程中你没有弹出 让你输入 root 用户密码的界面,那么恭喜你遇到跟我一样的 bug了,
默认 mysqld 服务是启动的,然后查看 配置文件
$ sudo cat /etc/mysql/debian.cnf
Copy the Code
大家来看看用户名密码是啥,我都乐了
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = root
password =
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = root
password =
socket = /var/run/mysqld/mysqld.sock
basedir = /usr
Copy the Code
是的 你没看错,password是 空,逗我呢吧,这咋登陆啊?
然后 我就试了一下 果然登录不了
$ mysql -u root -p
Copy the Code
至此我完全懵逼了,无法登录 root 用户了,基本操作你都干不了。
然后我试过 修改 my.cfn 文件,先跳过密码验证,然后重启 mysqld 服务,再登录
是可以的,但是我这时候修改 root 用户密码为 123456 后,再修改 my.cfn文件,打开密码验证登录,
就无法登录了还是 上边的错误。
简直无语啊
还不如之前的呢,之前 deepin.cfn 文件 明明是有密码的啊,郁闷了
各位大佬求帮忙啊,在线等,急!!!!
Reply
Like 0
Favorite
View the author
All Replies
王猛龙
deepin
2019-05-12 18:20
#1
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
一直报这个错误
Reply
Like 0
View the author
王猛龙
deepin
2019-05-12 20:07
#2
我自问自答了
亲测有效
原因是mysql 数据问题
1.先修改 /etc/mysql/my.cfn 文件,添加如下代码
# skip password vliade in login
[mysqld]
skip-grant-tables
Copy the Code
2.重启服务:
sudo service mysqld restart
Copy the Code
3.登录mysql 数据库:
mysql -uroot -p
Enter password: #直接回车,就能登录了
Copy the Code
4.选择 mysql 数据库,更新 user表中 root 字段即可:
use mysql # 挨个执行
update user set authentication_string=password("root") where User="root";
update user set Password=password("root") where User="root";
update user set plugin='mysql_native_password' where User="root";
Copy the Code
5. 再次修改 /etc/mysql/my.cfn 文件,注释第一步新加的那两行代码
6.重启 mysqld 服务即可
Reply
Like 0
View the author
mzking
deepin
2019-05-13 01:26
#3
一般来说装完了是要新建一个root用户刷新权限的,不知道这个方法你试过了没,我每次都是这方法
https://www.ph0en1x.space/2018/09/06/ubuntu_mysql/
Reply
Like 0
View the author
199******15
deepin
2019-05-13 05:08
#4
用docker吧,几分钟就解决的事,以后也不怕宿主机升级什么的
Reply
Like 0
View the author
Please
sign
in first
Featured Collection
Change
[Tutorial] deepin25 WSL Offline Installation Guide
UOS AI 2.8 Released! Three New Intelligent Agents & Major Evolution
Solid Q&A | deepin 25 Common Questions – The Immutable System Edition
New Thread
Popular Events
More
直接使用 apt 安装
如果安装过程中你没有弹出 让你输入 root 用户密码的界面,那么恭喜你遇到跟我一样的 bug了,
默认 mysqld 服务是启动的,然后查看 配置文件
然后 我就试了一下 果然登录不了
然后我试过 修改 my.cfn 文件,先跳过密码验证,然后重启 mysqld 服务,再登录
是可以的,但是我这时候修改 root 用户密码为 123456 后,再修改 my.cfn文件,打开密码验证登录,
就无法登录了还是 上边的错误。
简直无语啊
还不如之前的呢,之前 deepin.cfn 文件 明明是有密码的啊,郁闷了
各位大佬求帮忙啊,在线等,急!!!!