mysql ERROR 1045 (28000): Access denied for user 可能解决方法分析

在实际登录redmine的过程中,我们遇到了如下的error

ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)

ERROR 1045 (28000): Access denied for user ‘redmine‘@‘localhost‘ (using password: YES)

Solution 1---空用户error.

Solution 2---Windows 重置mysql root账户密码.

Solution 2---Linux 重置mysql root账户密码.

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

以下结合网上的解决方案进行了初步分析:

Solution 1---空用户error

1、停用mysql服务:

# service mysql stop

2、输入命令:

# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

3、登入数据库:

# mysql -u root mysql

4、mysql> use mysql;

5、mysql> select user,host,password from user;

结果如下:

+------+-----------------------+----------+
| user | host                            | password |
+------+-----------------------+----------+
| root | %                                 | mima |
| root | localhost.localdomain  | mima |
| root | 127.0.0.1                     | mima |
|        | localhost                      |           |
|         | localhost.localdomain |           |
+------+-----------------------+----------+

6、将上面查询出来的空用户删除:

mysql> delete from user where user=‘ ‘;

7、退出数据库:

mysql> quit

8、启动mysql服务:

# service mysql start

9、重新用命令:

mysql -u root -p

登录,OK!

Solution 2---Windows 重置mysql root账户密码.

搜索Windows上mysql目录的my.ini文件,

在[mysqld]这个条目下加入  skip-grant-tables
保存退出后重启mysql

1.点击“开始”->“运行”(快捷键Win+R)。

  2.停止:输入 net stop mysql

  3.启动:输入 net start mysql

这时候在cmd里面输入mysql -u root -p就可以不用密码登录了,出现password:的时候直接回车可以进入,不会出现ERROR 1045 (28000),但很多操作都会受限制,因为我们不能grant(没有权限)。

按下面的流程走(红色部分为输入部分,粉红色的是执行后显示的代码不用输入):

1.进入mysql数据库:

mysql> use mysql;
Database changed

2.给root用户设置新密码,蓝色部分自己输入:
mysql> update user set password=password("新密码") where user="root";
Query OK, 1 rows affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

3.刷新数据库
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

4.退出mysql:
mysql> quit
Bye

改好之后,再修改一下my.ini这个文件,把我们刚才加入的"skip-grant-tables"这行删除,保存退出再重启mysql就可以了。

Solution 2---Linux 重置mysql root账户密码.

1、停用mysql服务:

# service mysql stop

2、输入命令:

# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

3、登入数据库:

# mysql -u root mysql

4、mysql> use mysql;

5、mysql> update user set password=password("新密码") where user="root";

Query OK, 0 rows affected (0.13 sec)
Rows matched: 4 Changed: 0 Warnings: 0

6、刷新数据库

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

mysql> quit
Bye

6、重启 $ sudo service mysql start

mysql start/running, process 12719

7、登录:

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 49
Server version: 5.5.54-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2016, 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>

成功登录。

欢迎交流!

参考:

http://www.jb51.net/article/82421.htm

http://blog.sina.com.cn/s/blog_759a5a7c01017dj0.html

时间: 2024-07-30 21:06:54

mysql ERROR 1045 (28000): Access denied for user 可能解决方法分析的相关文章

mysql ERROR 1045 (28000): Access denied for user的解决方法

问题描述: 今日在10.240.210.60上面远程连接10.240.210.188的数据库时,弹出以下报错 mysql ERROR 1045 (28000): Access denied for user 上网搜索后了解到,是由于10.240.210.188没有给10.240.210.60这台机器赋予连接权限引起的. [解决办法] 在10.240.210.188连上mysql [[email protected] ~]# mysql -uroot -ppassword 赋予10.240.210

Mac下解决mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Maybe updating the package the updater overwrote the root password. To restore it: Stop mysqld deamons. $ sudo service mysqld stop Go to mysql/bin directory $ cd /usr/bin Start a mysql deamon with this option: $ sudo mysqld_safe --skip-grant-tables O

转-解决Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'问题

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) Red Hat Enterprise Linux 5服务器上mysql启动报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)原因1-启动命令错误:我开始的时候直接输入命令:mysql start 正确的启动命令是:

XMPP - Mysql ERROR 1045 (28000): Access denied for user 'root'@'l

Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'(using password: YSE),这个错误搞得很郁闷,仔细分析之后,知道这个报错和密码有关,可能是密码在配置mysql的时候异常,所以导致我们没有正确的密码,知道问题后,立即想到解决办法了,那就是重新设置一个密码,方法如下 1.先关闭mysql并设置密码 1 #sudo /etc/init.d/mysql stop 2 #sudo mysqld_safe

解决Mysql ERROR 1045 (28000): Access denied for user

在ubuntu server 12.04中,安装mysql后,使用命令登录mysql居然报错了,Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'(using password: YSE),这个错误搞得很郁闷,仔细分析之后,知道这个报错和密码有关,可能是密码在配置mysql的时候异常,所以导致我们没有正确的密码,知道问题后,立即想到解决办法了,那就是重新设置一个密码,方法如下 1.先关闭mysql并设置密码 #s

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

1) /etc/init.d/mysqld stop 2) mysqld_safe --skip-grant-tables & 3) mysql -u root 4) Setup new MySQL root user passworduse mysql;#update user set password=PASSWORD("123456") where User='root';#update mysql.user set password=PASSWORD("123

MYSQL ERROR 1045 (28000): Access denied for user 'neeky'@'Nee' (using password: YES)

情况: mysql -h 192.168.1.7 -u neeky -p 本来这样就可以连接上mysql服务的了, 可是它会报这个错“ERROR 1045 (28000): Access denied for user 'neeky'@'Nee' (using password: YES)” 解决方法 第一步:用root 用户登录进去把mysql.user这个表中neeky对应的行的host 改成% 1.mysql -uroot -p 2.use mysql; 3.update user set

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

安装mysql后,使用命令登录mysql居然报错了,Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'(using password: YSE),这个错误搞得很郁闷,仔细分析之后,知道这个报错和密码有关,可能是密码在配置mysql的时候异常,所以导致我们没有正确的密码,知道问题后,立即想到解决办法了,那就是重新设置一个密码,方法如下 1.先关闭mysql并设置密码 #sudo /etc/init.d/mysql

解决Mysql ERROR 1045 (28000)“Access denied for user 'root'@'localhost'”

1. 查看某个用户的权限 mysql> show grants for 'episode'@'%'; 2.为用户添加某个数据库的权限: mysql> GRANT ALL PRIVILEGES ON `episode_cc`.* TO 'episode'@'%' WITH GRANT OPTION; 如果是给所有数据库的权限,则是:mysql>GRANT ALL PRIVILEGES ON *.* TO 'episode'@'%' WITH GRANT OPTION; 解决Mysql ER