在实际登录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

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

  1. 【MySQL】ERROR 1045 (28000): Access denied for user的解决方法

    去官网下载压缩版的MySQL Server,解压配置path环境变量后.然后克隆my-default.ini创建my.ini文件,在文件中[mysqld]下面配置basedir和datadir bas ...

  2. 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 ...

  3. 【技术贴】解决Mysql ERROR 1045 (28000): Access denied for

    今天Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' 肯定是密码不对了.那么重置一下密码吧. 打开 cmd 输入以 ...

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

    MySQL安装完server端和客户端后,登录Mysql时报错:[root@rhel204 MySQL 5.6.23-RMP]# mysqlERROR 2002 (HY000): Can't conn ...

  5. MYSQL ERROR 1045 (28000) Access denied for user (using password YES)问题的解决

    我的Linux是Centos6.7的版本,本机上Mysql突然怎么连接都进不去 报错:MYSQL ERROR 1045 (28000) Access denied for user (using pa ...

  6. MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost'解决

    MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost'解决: # /etc/init.d/mysql stop # my ...

  7. MySql ERROR 1045 (28000): Access denied 错误

    [MySql ERROR 1045 (28000): Access denied 错误] 即登陆错误,使用MySql登陆时,需使正确的username/passwd.通过 -u -p 参数即可. My ...

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

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) Red Hat Enterpris ...

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

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)   Red Hat Enterpr ...

随机推荐

  1. 17 Privacy Lost:Dose Anybody Care ? 失去隐私,有人在乎吗 ?

    Privacy Lost:Dose Anybody Care ? 失去隐私,有人在乎吗 ? ①Someday a stranger will read your e-mail without your ...

  2. [operator]Ubuntu server 18 设置静态IP

    root@ubuntu-MesosMaster-Marathon:~# cat /etc/netplan/-cloud-init.yaml # This file is generated from ...

  3. 03-vue-router

    前端路由的实现原理 <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

  4. Leed code 11. Container With Most Water

    public int maxArea(int[] height) { int left = 0, right = height.length - 1; int maxArea = 0; while ( ...

  5. 6) mvn archetype:create-from-project

    cd %old%mvn archetype:create-from-projectcd %old%/target/generated-sources/archetype mvn installcd % ...

  6. Jersey服务端

    问世间情为何物,直叫人一声呵呵. 上个项目写的jersey restful服务端,怎么都是正确的,没什么问题.结果这个项目写了,呵呵了,真的呵呵了,怎么搞都有问题. 总是报错,对json的类型报错,无 ...

  7. Mina的ssl加密

    前面写的Mina的示例,都是可以通过telnet登录的,并且可以相互交互. 现在采用ssl加密的方式,对建立连接时,进行加密连接.这样,双方只有统一的加密,然后才可以连接. 密钥的生成之前有说过,里面 ...

  8. DBCC--CHECKDB--结果收集

    --由宋沄剑提供 CREATE TABLE [dbo].[dbcc_history]( [Error] [int] NULL, [Level] [int] NULL, [State] [int] NU ...

  9. JAVA 从头开始<五>

    一.反编译 java代码 javac编译后的class文件,想要看得懂,需要使用反编译工具 使用bin目录下的java开发工具(javap.exe) 二.构造函数 三.构造代码块 1.类中可能有多个构 ...

  10. Spring Boot项目搭建

    1.Spring Boot概述 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人 ...