最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

[已解决]CentOS中用root去登录mysql出错:ERROR 1045 28000 Access denied for user root@localhost using password NO

CentOS crifan 1650浏览 0评论

折腾:

[已解决]在CentOS中创建对应的mysql数据库

期间,去用root去登录mysql,结果出错:

(SIPEvents) ➜  SIPEvents mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
(SIPEvents) ➜  SIPEvents mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
(SIPEvents) ➜  SIPEvents mysql -u root -p
Enter password: 
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数据库时常见故障问题的分析与解决 – lioncode的专栏 – 博客频道 – CSDN.NET

完整过程解决 ERROR 1045 (28000): Access denied for user ‘mysql’@’localhost’ (using password: NO) – nel0511的专栏 – 博客频道 – CSDN.NET

mysql Access denied for user root@localhost错误解决方法总结-mysql教程-数据库-壹聚教程网

permissions – ERROR 1045(28000) : Access denied for user ‘root@localhost’ (using password: no ) – Ask Ubuntu

mysql – ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES) – Stack Overflow

(SIPEvents) ➜  SIPEvents mysql -u root
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)

mysql登录报错“Access denied for user ‘root’@’localhost’ (using password: YES”的处理方法 – 苦咖啡’s运维之路 – 51CTO技术博客

UPDATE mysql.user SET Password=PASSWORD(‘Jiandao123′) WHERE User=’root’;

update user set password=PASSWORD(“Jiandao123”) where User=’root’;

完整的操作:

(SIPEvents) ➜  SIPEvents service mysqld stop
Stopping mysqld:                                           [  OK  ]
(SIPEvents) ➜  SIPEvents mysqld_safe –skip-grant-tables
160911 15:12:48 mysqld_safe Logging to ‘/var/log/mysqld.log’.
160911 15:12:48 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
^C^C^C^Cq
^Z
[1]  + 17764 suspended  mysqld_safe –skip-grant-tables
(SIPEvents) ➜  SIPEvents mysqld_safe –skip-grant-tables &
[2] 17870
(SIPEvents) ➜  SIPEvents 160911 15:13:22 mysqld_safe Logging to ‘/var/log/mysqld.log’.
160911 15:13:23 mysqld_safe A mysqld process already exists
[2]  – 17870 exit 1     mysqld_safe –skip-grant-tables
(SIPEvents) ➜  SIPEvents 
(SIPEvents) ➜  SIPEvents 
(SIPEvents) ➜  SIPEvents 
(SIPEvents) ➜  SIPEvents netstat -tupln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:10022               0.0.0.0:*                   LISTEN      17286/docker-proxy  
tcp        0      0 0.0.0.0:9000                0.0.0.0:*                   LISTEN      19706/docker-proxy  
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      17851/mysqld        
tcp        0      0 127.0.0.1:6379              0.0.0.0:*                   LISTEN      19659/redis-server  
tcp        0      0 0.0.0.0:9003                0.0.0.0:*                   LISTEN      19669/docker-proxy  
tcp        0      0 127.0.0.1:8080              0.0.0.0:*                   LISTEN      16058/python        
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      20416/nginx         
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1335/sshd           
tcp        0      0 0.0.0.0:3000                0.0.0.0:*                   LISTEN      17240/docker-proxy  
tcp        0      0 0.0.0.0:8088                0.0.0.0:*                   LISTEN      29962/docker-proxy  
tcp        0      0 0.0.0.0:5432                0.0.0.0:*                   LISTEN      18421/docker-proxy  
tcp        0      0 0.0.0.0:8000                0.0.0.0:*                   LISTEN      19505/docker-proxy  
tcp        0      0 0.0.0.0:32771               0.0.0.0:*                   LISTEN      8748/docker-proxy   
tcp        0      0 0.0.0.0:32772               0.0.0.0:*                   LISTEN      8782/docker-proxy   
udp        0      0 192.168.42.1:123            0.0.0.0:*                               1346/ntpd           
udp        0      0 115.29.173.126:123          0.0.0.0:*                               1346/ntpd           
udp        0      0 10.161.170.247:123          0.0.0.0:*                               1346/ntpd           
udp        0      0 127.0.0.1:123               0.0.0.0:*                               1346/ntpd           
udp        0      0 0.0.0.0:123                 0.0.0.0:*                               1346/ntpd           
(SIPEvents) ➜  SIPEvents 
(SIPEvents) ➜  SIPEvents 
(SIPEvents) ➜  SIPEvents 
(SIPEvents) ➜  SIPEvents 
(SIPEvents) ➜  SIPEvents mysqld_safe –skip-grant-tables &
[2] 17987
(SIPEvents) ➜  SIPEvents 160911 15:13:40 mysqld_safe Logging to ‘/var/log/mysqld.log’.
160911 15:13:40 mysqld_safe A mysqld process already exists
[2]  – 17987 exit 1     mysqld_safe –skip-grant-tables
(SIPEvents) ➜  SIPEvents mysql -u roo    
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 mysql.user SET Password=PASSWORD(‘Jiandao123′) WHERE User=’root’;
    ‘> flush privileges;
    ‘> quit
    ‘> Ctrl-C — exit!
Aborted
(SIPEvents) ➜  SIPEvents mysql -u roo                     
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> help
For information about MySQL products and services, visit:
   http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
   http://dev.mysql.com/
To buy MySQL Enterprise support, training, or other products, visit:
   https://shop.mysql.com/
List of all MySQL commands:
Note that all text commands must be first on line and end with ‘;’
?         (\?) Synonym for `help’.
clear     (\c) Clear the current input statement.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
edit      (\e) Edit command with $EDITOR.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
nopager   (\n) Disable pager, print to stdout.
notee     (\t) Don’t write into outfile.
pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
system    (\!) Execute a system shell command.
tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings  (\W) Show warnings after every statement.
nowarning (\w) Don’t show warnings after every statement.
For server side help, type ‘help contents’
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set password=PASSWORD(“Jiandao123”) where User=’root’;
Query OK, 3 rows affected (0.01 sec)
Rows matched: 3  Changed: 3  Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit;
Bye
(SIPEvents) ➜  SIPEvents service mysqld start
Starting mysqld:                                           [  OK  ]
(SIPEvents) ➜  SIPEvents mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
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>

即:

1.先去停止mysql服务器

service mysqld stop

2.不需要验证权限就进入mysql,为的是后来修改root的密码

mysqld_safe –skip-grant-tables &

其中:

&表示在后台运行,否则如果像我这里,只有一个SSH2连接到对应服务器

该进程不退出,就没法再连接了。

而如果是可以另外开shell终端,则可以不加&,另开shell去操作。

3.进入mysql后去修改root的密码

use mysql
update user set password=PASSWORD(“YourNewPassrod”) where User=’root’;
flush privileges;
quit;

4.再次启动mysql服务

service mysqld start

5.最后去验证用你的新密码

mysql -u root -p
输入新密码,即可登录进去

转载请注明:在路上 » [已解决]CentOS中用root去登录mysql出错:ERROR 1045 28000 Access denied for user root@localhost using password NO

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
62 queries in 0.215 seconds, using 18.93MB memory