mysql Access denied for user ‘root’@’localhost’ (using password: YES)解决方法_Mysql

今天在启动mysql时出现以下问题:

[root@www ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

网上的答案是各种各样的,最终解决问题的方法总结为以下,好多都是没有设置初始密码造成此问题的。

解决方法如下:

[root@www ~]# service mysqld stop   #先关闭mysql服务
Stopping mysqld:                      [ OK ]
[root@www ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@www ~]# mysql -u root -p      #关闭服务后又出现如下问题
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@www ~]# mysql -u root mysql    #键入此命令进入mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> update user set password=password('123') where user='root' and host='localhost';  ---->修改root的密码
Query OK, 1 row affected (0.04 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush priviledge;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'priviledge' at line 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> \q
Bye
[root@www ~]# mysql -u root -p           ------>重新进入
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> \q
Bye

到此就完了!!

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索mysql
, access
, for
, denied
, user
, (using
, password:
YES)
,以便于您获取更多的相关知识。

时间: 2024-09-03 21:12:08

mysql Access denied for user ‘root’@’localhost’ (using password: YES)解决方法_Mysql的相关文章

mysql启动提示 access denied for user root@localhost(using password:YES) 解决办法总结

关键是看:Access denied for user 'root'@'localhost' (using password: YES)' 从错误中可以看出你的权限是对localhost的访问没有放开. 于是你可以使用如下命令来放开权限: 解决办法 1. 管理员登陆系统,停止mysql服务或者结束mysqld-nt进程: 2. 进入命令行,来到mysql的安装目录.假设安装目录为 d:mysql , CMD进入命令行: 3. 运行 D:Program FilesMySQLMySQL Server

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

案例环境:              操作系统 :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 'root'@'loc

mysql Access denied for user root@localhost错误解决方法总结

错误代码 1045 Access denied for user 'root'@'localhost' (using password:YES) 解决办法是重新设置root用户密码,在Windows平台下操作步骤如下: 1.以系统管理员身份登录到系统: 2.如果MySQL服务器正在运行,停止它. 如果是作为Windows服务运行的服务器,进入服务管理器:开始菜单->控制面板->管理工具->服务 如果服务器不是作为服务而运行的,可能需要使用任务管理器来强制停止它. 3.创建1个文本文件,并

MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)的真正原因

在博客Linux mysql 5.6: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)里 面,我介绍了一下安装MySQL后登陆MySQL时会遇到ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 这个错误,当时不知道真正的原因,搜索了一些网上的资料,测试验证了如何解决

MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 的原因分解决办法_Mysql

MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 的解决办法和原因 这两天下载了MySQL5.7.11进行安装,发现到了初次使用输入密码的时候,不管怎样都进不去,即使按照网上说的在mysqld 下面添加skip-grant-tables也是不行,后来研究了两天,终于找出原因和解决办法. 复制代码 代码如下: [mysqlld] skip-grant-tables: 原因

mysql5.7 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

初次安装mysql,net start mysql,然后输入mysql -u root -p,出现enter password,我直接点击回车,结果出现如果下错误:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).网上看了很多方法,都是千篇一律的,没有解决我的问题使用:set password for 'root'@'localhost' =password('');flush p

mysql Access denied for user root@localhost

从网上找了一个解决方案解决了,在这里记录一下: 1. 管理员登陆系统,停止mysql服务或者结束mysqld-nt进程: 2. 进入命令行,来到mysql的安装目录.假设安装目录为 d:/mysql/ , CMD进入命令行: 3. 运行 D:/Program Files/MySQL/MySQL Server 5.5/bin/mysqld-nt --skip-grant-tables启动mysql,关闭权限的检查: 4. 运行 D:/Program Files/MySQL/MySQL Server

centOS下mysql-ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

系统centOS-6.3 方法操作很简单,如下:# /etc/init.d/MySQL stop# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &# mysql -u root mysql # mysql>use mysql ;mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root' and host='root'

mysql:error: 'Access denied for user 'root'@'localhost'

# mysqladmin -uroot -p password 'newpassword' Enter password: mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)' 现在终于被我找到了解决方法,如下(请先测试方法三,谢谢!): 方法一: # /etc/init.d/mysql stop #