刚刚安装好了mysql数据库,root用户登录没有问题,但是在创建了新的数据库后却无法登录,报“ERROR 1045 (28000): Access denied for user”这样的错误,下面对这个错误进行重演,首先以root用户登录:
[root@zabbix ~]# mysql -uroot -proot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.16-log MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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>
然后创建数据库wgldjc:
mysql> create database wgldjc;
Query OK, 1 row affected (0.00 sec)
授予权限:
mysql> GRANT ALL PRIVILEGES ON wgldjc.* TO wgldjc@'%' IDENTIFIED BY 'wgldjcpassword';
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql>
mysql> exit
登录数据库wgldjc时报错:
[root@zabbix ~]# mysql -uwgldjc -pwgldjcpassword
ERROR 1045 (28000): Access denied for user 'wgldjc'@'localhost' (using password: YES)
刷新一下权限,发现还是不行:
[root@zabbix ~]# mysql -uroot -proot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.16-log MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@zabbix ~]# mysql -uwgldjc -pwgldjcpassword
ERROR 1045 (28000): Access denied for user 'wgldjc'@'localhost' (using password: YES)
[root@zabbix ~]#
在网上找到了一种方法,登录数据库mysql,删除user表中user列为空格的行:
[root@zabbix ~]# mysql -uroot -proot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.5.16-log MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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> use mysql
Database changed
mysql> select host,user,password from user;
+-----------+--------+-------------------------------------------+
| host | user | password |
+-----------+--------+-------------------------------------------+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| zabbix | root | |
| 127.0.0.1 | root | |
| ::1 | root | |
| localhost | | |
| zabbix | | |
| % | wgldjc | *70E31422FB5C781D112D6C944FAB09312088255B |
+-----------+--------+-------------------------------------------+
7 rows in set (0.00 sec)
mysql> delete from user where user=' ';
Query OK, 2 rows affected (0.00 sec)
mysql> exit
Bye
下面再进行尝试登录数据库wgldjc,依然报错:
[root@zabbix ~]# mysql -uwgldjc -pwgldjcpassword
ERROR 1045 (28000): Access denied for user 'wgldjc'@'localhost' (using password: YES)
刷新权限
[root@zabbix ~]# mysql -uroot -proot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.5.16-log MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
成功登录:
[root@zabbix ~]# mysql -uwgldjc -pwgldjcpassword
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.5.16-log MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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> exit
Bye
[root@zabbix ~]#
再次创建数据库后登录不再报此错:
[root@zabbix ~]# mysql -u root -p root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.5.16-log MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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> create database tjp;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON tjp.* TO tjp@'%' IDENTIFIED BY 'tjp';
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@zabbix ~]# mysql -utjp -ptjp
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.5.16-log MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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>
注:为了使博客更加完善,便于更好的分享,请读者为文章中的错误进行指正,博主会定期更正,谢谢!
相关推荐
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 解决: 1.打开在创建mysql容器时挂载的conf目录下的mysqld.cnf(如下文件) 我创建docker的姿势 2.进入mysqlId.cnf文件中在...
首先是不知道怎么忽然mysql用命令行,workbench都登录不了,都提示’Access denied for user ‘root’@’localhost’。 数据库卸载重装了几次都不行。好像感觉数据清理不干净。解决的过程遇到的坑,这里记录分享下。...
在MySQL中,错误号1045 (28000)通常表示“Access denied for user”,这是一个常见的权限问题,意味着指定的用户无法使用提供的密码登录数据库服务器。本篇文章将详细探讨这个问题的原因以及两种可能的解决方案。 #...
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO) 第一步:编辑mysql安装目录中的配置文件my.ini,在[mysqld]这个条目下加入 skip-grant-tables 如下图: 保存退出后 第二...
在使用MySQL数据库时,有时会出现一个常见的错误:`ERROR 1045 (28000): Access denied for user "root"@"localhost" (using password: YES)`。这个错误表明,你尝试用root用户登录MySQL,但系统拒绝了你的访问,...
在使用MySQL数据库时,有时会出现一个常见的错误,即"ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)"。这个错误表明,尝试以root用户身份登录MySQL服务器时,由于认证失败...
在新安装MySQL后,有时可能会遇到登录问题,特别是当你尝试使用`mysql -uroot -p`命令并输入默认密码时,系统返回`ERROR 1045 (28000): Access denied for user`错误,这意味着你的登录凭据无效或者你没有足够的权限...
Unhandled rejection SequelizeAccessDeniedError: Access denied for user 'lupeng'@'localhost' (using password: YES) 这是Node在使用Sequlize连接Mysql数据时报的错,关键看冒号后面的错误:访问拒绝,关键是...
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) 提示的是用户访问被拒绝,原因是密码不正确,但是我们明明配置的是正确的密码,原因就在yml中: spring: datasource: ...
MySQL ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO) 的解决办法和原因 这两天下载了MySQL5.7.11进行安装,发现到了初次使用输入密码的时候,不管怎样都进不去,即使...
本教程将详述如何在Ubuntu 18.0.4上安装MySQL,并解决在登录时遇到的"ERROR 1698 (28000): Access denied for user 'root'@'localhost'"的问题。 首先,安装MySQL服务可以使用Ubuntu的包管理器`apt`。执行以下命令...
环境变量配置错误 mysql 命令行错误 ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: N
当你尝试运行`python manage.py migrate`命令来同步数据库模型时,如果遇到`django.db.utils.OperationalError: (1045, "Access denied for user ‘账号’@’localhost’ (using password: YES)")`这样的错误,这...
ERROR 1044 (42000): Access denied for user ”@’localhost’ to database ‘python’ 2. 解决方法: 执行以下命令进入控制台: mysql –user=root -p 输入root用户的密码即可进入mysql控制台: 创建数据库: ...
主要给大家介绍了如何解决mysql在创建数据库后出现:Access denied for user 'root'@'%' to database 'xxx'的错误提示,文中介绍的非常详细,需要的朋友可以参考借鉴,下面来一起看看吧。
主要介绍了MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 的原因分解决办法的相关资料,需要的朋友可以参考下
当遇到“Access denied for user 'root'@'localhost'”这样的MySQL登录错误时,通常意味着系统拒绝了root用户的登录请求,这可能是由于多种原因引起的,包括但不限于密码错误、权限设置问题或者MySQL配置文件的变动...
MySQL密码忘了,可以进行重置设置。安全模式的进入,操作。