博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ubuntu19.04+mysql5.7 中 Mysql:ERROR 1698 (28000): Access denied for user 'root'@'localhost'
阅读量:7098 次
发布时间:2019-06-28

本文共 1587 字,大约阅读时间需要 5 分钟。

  hot3.png

首先出现的情况是mysql -uroot -p123456可以登录,

但是网站配置了账号却显示Mysql:ERROR 1698 (28000): Access denied for user 'root'@'localhost'。

那就直接登录进去执行下面一条语句即可。 

mysql.user表里authentication_string这个字段是密码,以后会逐渐废弃password字段

UPDATE mysql.user SET authentication_string=PASSWORD('root的密码'), PLUGIN='mysql_native_password' WHERE USER='root';

如果命令行都登不上去的话,

使用cat命令查看默认用户名密码。

sudo cat /etc/mysql/debian.cnf

root:~# sudo cat /etc/mysql/debian.cnf 

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

使用默认用户名密码登录

root@ubuntu:~# mysql -udebian-sys-maint -p0XRu7iGdhb6UT8Afmysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 63Server version: 5.7.25-1 (Ubuntu)Copyright (c) 2000, 2019, 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.mysql>

执行刚才那个更新语句,

退出来

重启mysql。

生效。

嗯。

实在解决不了,就卸载重装吧。

root@ubuntu:~#rm /var/lib/mysql/ -Rroot@ubuntu:~#rm /etc/mysql/ -Rroot@ubuntu:~#apt-get autoremove mysql* --purgeroot@ubuntu:~#apt-get remove apparmorroot@ubuntu:~#apt-get updateroot@ubuntu:~#apt-get install mysql-server

转载于:https://my.oschina.net/marhal/blog/3042388

你可能感兴趣的文章
iOS自动布局的学习
查看>>
单利模式
查看>>
BZOJ2521:[SHOI2010]最小生成树(最小割)
查看>>
将execl里的数据批量导入数据库
查看>>
DOM笔记(一):HTMLDocument接口
查看>>
[ios]ipad下的splitViewController 让你的APP看起来酷酷的!
查看>>
【SICP练习】47 练习2.6
查看>>
抓交通肇事犯
查看>>
ABAP程序系统字段中英文详解
查看>>
ruby 可枚举模块Enumerable
查看>>
线阵CCD和面阵CCD
查看>>
[BZOJ 3211]花神游历各国(并查集+树状数组)
查看>>
Python中给文件加锁
查看>>
4.9Python数据类型(5)列表(新版)
查看>>
软件构造期末复习考点总结
查看>>
7 Django的模板层
查看>>
EF中Json序列化对象时检测到循环引用的解决办法
查看>>
词向量概况
查看>>
css3 画圆记录
查看>>
javascript中级
查看>>