mysql登录错误:'Access denied for user 'root'@'localhost'
首先是不知道怎么忽然mysql用命令行,workbench都登录不了,都提示'Access denied for user 'root'@'localhost'。
数据库卸载重装了几次都不行。好像感觉数据清理不干净。解决的过程遇到的坑,这里记录分享下。
有效的操作记录下:
1、首先是跳过权限登录mysql,查看user表,
停止mysql服务~$ sudo service mysql stop
以安全模式启动MySQL~$ sudo mysqld_safe --skip-grant-tables &
注意:
可能提示mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exist
解决方法:(笔者尝试发现必须加sudo)
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
再次执行上面安全模式启动mysql ~$ sudo mysqld_safe --skip-grant-tables &
这次提示语句显示了,mysqld_safe Staring mysqld deamon with database from /var/lib/mysql
这次登录可以不用密码:mysql -u root 回车就登录了
sql语句查询mysql.user表的情况,如下:
加图片(以后补)
还有人提议如下这么做,没尝试
Open & Edit /etc/my.cnf or /etc/mysql/my.cnf, depending on your distro.
Add skip-grant-tables under [mysqld]
2、发现user的plugin为socket_plugin,改为mysql_native_password
修改root的plugin权限:
update mysql.user set authentication_string=PASSWORD('newPwd'), plugin='mysql_native_password' where user='root';
flush privileges;
quit;
(注意这里修改一定要正确,免得跟笔者一样,粗心的把plugin修改的内容少些了一个字母,又有下面的折腾)
3、user表还有其他用户,root不能登录,用其他的用户登录也行啊。查询了发现一下有效操作:
在mysql的安装目录,一般在 /etc/mysql里面有个debain.cnf文件,里面有user,password,用这个用了登录,密码最后复制,然后就又可以修改user表root的plugin,操作同上。
重启mysql服务, sudo service mysql restart;
用root用户就可以登录。
参考博客:
MySQL ERROR 1698 (28000) 错误 https://www.cnblogs.com/leolztang/p/5094930.html
mysql 查看当前使用的配置文件my.cnf的方法 https://blog.csdn.net/fdipzone/article/details/52705507
linux -- Ubuntu查看修改mysql的登录名和密码、安装phpmyadmin https://www.cnblogs.com/hf8051/p/4775627.html
mysql登录错误:'Access denied for user 'root'@'localhost'的更多相关文章
- Windows系统下MySQL数据库出现Access denied for user 'root'@'localhost' (using password:YES) 错误
Windows系统下MySQL数据库出现Access denied for user 'root'@'localhost' (using password:YES) 错误,(root密码错误) 处理方 ...
- mySQL 5.7版 解决密码登录失败Access denied for user 'root'@'localhost' (us
mySQL 5.7版 解决密码登录失败Access denied for user 'root'@'localhost' (us 2016-03-05 ...
- mysql error: Access denied for user 'root'@'localhost' (using password: YES)
昨天重装了下系统,安装好mysql后,安装了客户端工具连接mysql,提示Access denied for user 'root'@'localhost' (using password: YES) ...
- MySQL密码正确却无法本地登录-1045 Access denied for user 'root'@'localhost' (using password:YES
MySQL密码正确却无法本地登录 报错如下: ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password ...
- mysql出错:Access denied for user 'root'@'localhost' (using password: YES)
网站链接mysql数据库的时候,连接不上,并报出错误:Access denied for user 'root'@'localhost' (using password:YES) 这是个相当恼火的问题 ...
- mac下mysql 1045 (28000): Access denied for user 'root'@'localhost' (using password:
新入了mac pro,安装好mysql后,用终端进入mysql遇到个问题: 1045 (28000): Access denied for user 'root'@'localhost' (using ...
- phpMyAdmin出现错误 Access denied for user 'root'@'localhost' (using password: NO)
今天安装wmpp,之后启动后点击phpMyAdmin 报拒绝连接错误:#1045 - Access denied for user 'root'@'localhost' (using password ...
- Mac Mysql mysql_secure_installation Error: Access denied for user 'root'@'localhost' (using password: YES)
mysql由brew安装, 期间好像自动更新了一次 然后再次执行mysql_secure_installation, 输入root密码后报错, 重装mysql还是不行 Error: Access de ...
- eclipse不正常编译导致错误:Access denied for user 'root'@'localhost' (using password: YES)
使用eclipse连接mysql报错:Access denied for user 'root'@'localhost' (using password: YES) 连接代码没有任何问题,网上找了很多 ...
- mysql启动问题access denied for user 'root'@'localhost'(using password:YES)
安装Mysql后利用SQLyogEnt启动是提示“access denied for user 'root'@'localhost'(using password:YES)”,开始我还为是因为是密码问 ...
随机推荐
- 2018 牛客国庆集训派对Day4 - H 树链博弈
链接:https://ac.nowcoder.com/acm/contest/204/H来源:牛客网 题目描述 给定一棵 n 个点的树,其中 1 号结点是根,每个结点要么是黑色要么是白色 现在小 Bo ...
- CodeForces-Round524 A~D
A. Petya and Origami time limit per test 1 second memory limit per test 256 megabytes input stan ...
- CF579 - A Raisinng bacteria
You are a lover of bacteria. You want to raise some bacteria in a box. Initially, the box is empty. ...
- 不启动AndroidStudio直接启动其模拟器
1.找到自己电脑Android sdk的安装路径下的tools\emulator.exe 2.获取你要启动的模拟器的名称 我这里是Nexus 5X API 27,把名字中间的空格改为_,我这里就应该改 ...
- JS四种判断数据类型的方法:typeof、instanceof、constructor、Object.prototype.toString.call()
1.typeof 1 console.log(typeof ""); //string 2 console.log(typeof 1); //number 3 console.lo ...
- C语言每日一练——第1题
一.程序功能 程序的功能是:将大于整数m且紧靠m的k个素数存入数组xx.并把in.dat文件的内容输入到程序,并把输出结果输出道out.dat文件夹中例如:若输入17,5 则应该输入:19,23,29 ...
- c++ const问题小记
int* a = new int; const int* b = a; const int* a = new int; int* b = (int*)a; const int m = 10; int ...
- haproxy 在centos上cannot bind 端口的问题
setsebool -P haproxy_connect_any=1 要不把selinux干掉也行
- poj 1062 昂贵的聘礼 (有限制的最短路)
昂贵的聘礼 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 56594 Accepted: 17083 Descripti ...
- 基于C#WPF框架——动画
WPF提供了一个更高级的模型,通过该模型可以只关注动画的定义,而不必考虑它们的渲染方式.这个模型基于依赖项属性基础架构.本质上,WPF动画只不过是在一段时间间隔内修染方式.这个模型基于依赖项属性基础架 ...