mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)'

就当作自己忘记Mysql密码把,忘记密码的解决方法



一、mysql登录错误
mysqladmin: connect to server at ‘localhost‘ failed
error: ‘Access denied for user ‘root‘@‘localhost‘ (using password: YES)‘
无法修改密码
用 service mysqld stop
mysqld_safe --skip-grant-tables &
输入 mysql -uroot -p 回车进入
>use mysql;
> update user set password=PASSWORD("newpass")where user="root";
更改密码为 newpassord
> flush privileges; 更新权限
> quit 退出
service mysqld restart
mysql -uroot -p新密码进入

===========================================================
二,忘记本地root的登录密码
解决过程:
1、编辑/etc/my.cnf
在[mysqld] 配置部分添加一行
skip-grant-tables

2、保存后重启mysql
[[email protected] etc]# service mysqld restart
Shutting down MySQL. [ OK ]
Starting MySQL. [ OK ]

3、登录数据库重新设置root密码
[[email protected] ~]# mysql -uroot -p mysql
Enter password:
直接回车进入

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.47-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)

执行下列语句
mysql> update user set password=password("mysql") where user=‘root‘;
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

4、删除/etc/my.cnf文件中添加的“skip-grant-tables”行,重启mysql;
用新设的密码就能正常登录了;

=================================================

介绍一个非常有用的mysql启动参数—— --skip-grant-tables。 顾名思义,就是在启动mysql时不启动grant-tables,授权表。有什么用呢?当然是忘记管理员密码后有用。
操作方法:
1、杀掉原来进行着的mysql:
rcmysqld stop
或者:
service mysqld stop
或者:
kill -TERM mysqld
2、以命令行参数启动mysql:
/usr/bin/mysqld_safe --skip-grant-tables &
3、修改管理员密码:
use mysql;
update user set password=password(‘yournewpasswordhere‘) where user=‘root‘;
flush privileges;
exit;
4、杀死mysql,重启mysql

mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)'

时间: 2024-10-10 10:26:32

mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)'的相关文章

Mac Mysql mysql_secure_installation Error: Access denied for user 'root'@'localhost' (using password: YES)

mysql由brew安装, 期间好像自动更新了一次 然后再次执行mysql_secure_installation, 输入root密码后报错, 重装mysql还是不行 Error: Access denied for user 'root'@'localhost' (using password: YES) 原因是之前安装的mysql配置文件没有彻底清除 参照 http://stackoverflow.com/questions/4359131/brew-install-mysql-on-mac

【zabbix】connection to database 'zabbix' failed: [1045] Access denied for user 'root'@'localhost' (using password: NO)

前面安装的我就不说了,度娘上的很多: 关键是这个问题,网上的比较多,但是没有发现有用的: 问题:zabbix server is runing No 日志:/tmp/zabbix_server.log connection to database 'zabbix' failed: [1045] Access denied for user 'root'@'localhost' (using password: NO) 解决过程: 1)找到安装目录: [[email protected] init

mysql链接 显示 error: 'Access denied for user 'root'@'localhost' (using password: NO)'

解决方案 https://stackoverflow.com/questions/2995054/access-denied-for-user-rootlocalhost-using-passwordno mysql链接 显示 error: 'Access denied for user 'root'@'localhost' (using password: NO)' 原文地址:https://www.cnblogs.com/Draymonder/p/9828760.html

解决mysql“Access denied for user 'root'@'localhost'”

解决mysql“Access denied for user 'root'@'localhost'” 分类: linux 2011-01-14 00:23 147547人阅读 评论(3) 收藏 举报 mysqluseraccessmanager数据库system # mysql -uroot -pEnter password:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 使用网

phpmyadmin mysql Access denied for user 'root'@'localhost'问题解决

centos6.4 32位的vps上装了lnmp以后,phpmyadmin无法连接mysql服务器,ssh命令行里mysql -uroot -p 命令后老是出现拒绝连接的情况.php程序里也是拒绝连接.尝试过修改phpmyadmin的config.inc.php文件,尝试过修改my.cnf文件,尝试过修改php.ini文件,都不行.连 lnmp.org官方都找不到解决办法. 网上找了很多地方,脑袋都炸了..终于找到解决办法.. 解决办法地址:http://bbs.vpser.net/thread

MySQL报'Access denied for user 'root'@'localhost' (using password: NO)'错误的解决

当在命令提示符下执行该命令时,报下列错误 [[email protected]]# mysqladmin -u root password "sorry"mysqladmin: connect to server at 'localhost' failederror: 'Access denied for user 'root'@'localhost' (using password: NO)' 解决办法: [[email protected]]# mysql -u root -pEn

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

To start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -

Linux mysql 5.6: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

最近操作mysql 5.6, 出现了以下问题. 分享,感谢原著: 案例环境: 操作系统 :Red Hat Enterprise Linux Server release 5.7 (Tikanga) 64 bit 数据库版本 : Mysql 5.6.19 64 bit 案例介绍: 今 天开始学习mysql,遂先安装了Mysql 5.6.19 64bit 版本的数据库,结果安装成功了,但是使用root登录时遇到了ERROR 1045 (28000): Access denied for user '

Linux mysql 5.7: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

环境:mac10.12 来源:http://www.cnblogs.com/kerrycode/p/3861719.html 使用root登录时遇到了ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)错误. 如下所示 [[email protected] tmp]# rpm -ivh MySQL-server-5.6.19-1.rhel5.x86_64.rpm Preparing..