mysql Access denied for user ‘root’@’localhost’ (using password: YES)解决方法
程序员文章站
2024-02-28 15:05:40
今天在启动mysql时出现以下问题:
[root@www ~]# mysql -u root -p
enter password:
error 1045 (...
今天在启动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
到此就完了!!
上一篇: python脚本爬取字体文件的实现方法
推荐阅读
-
mysql Access denied for user ‘root’@’localhost’ (using password: YES)解决方法
-
MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passw
-
MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passw
-
Mysql Access denied for user ''@'localhost' to database 的一种解决方法
-
ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using passwor
-
ubuntu18.0.4安装mysql并解决ERROR 1698 (28000): Access denied for user ''root''@''localhost''
-
Linux连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)的解决
-
Docker容器安装的mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'
-
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
-
linux mysql忘记密码的多种解决或Access denied for user 'root'@'localhost'