在实际登录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. Struts has detected an unhandled exception

    这个问题是struts和jsp页面的配置之间产生了问题,就是struts里边的名字和jsp里用的名字不是同一个名字,所以无法识别,所以检查一下里边的命名.

  2. Linux将程序添加到服务的方法(通用)

    一:咱们通过这篇文章来演示怎么将某个程序作为服务(就类似Windows服务可以开机自动启动),这里以tomcat为例,已经亲测过: 二:步骤(最好用root用户来做这种事情,切换root用户记得su ...

  3. 常见XML解析器

    xpp3 官网 http://www.extreme.indiana.edu/xgws/xsoap/xpp/ 简介 Xml Pull Parser (in short XPP) is a stream ...

  4. hdu1089 Ignatius's puzzle

    题目 其实这道题不是很难,但是我刚开始拿到这道题的时候不知道怎么做, 因为这个式子我就不知道是干什么的: 65|f(x) 百度解释(若a/b=x...0  称a能被b整除,b能整除a,即b|a,读作& ...

  5. web问题

    模拟form提交过程中form(hidden)时:The frame requesting access has a protocol of "http", the frame b ...

  6. mysql中设置默认字符编码为utf-8

    使用过Linux的同志就知道,在Linux下安装mysql,尤其是使用yum安装的时候,我们是没法选择其默认的字符编码方式.这个就是一个比较头痛的问题,如果Linux数据库中使用到中文的时候,乱码问题 ...

  7. Window 64bit环境搭建Web Starter Kit

    最近在学习https://developers.google.com/web/fundamentals/这里的内容,其中就有一部分是安装Web Starter Kit的教程,我总结一下自己的安装过程. ...

  8. AndroidPn服务端部分bug解决方案

    目前推送的情况已经大致可以了,可以正常推送.但是要在实际生产中使用,要改进很多地方. 原本的版本,是不会对消息重新发送的.消息如果丢失,或者用户没有在线,消息也不会重新的发送.所以,这些问题都是要解决 ...

  9. JPA注解指南

    PA注解持久化类很方便,需要jar包:ejb3-persistence.jar.我用以下三个类来说明用法. @SuppressWarnings("serial") @Entity ...

  10. Lucene.net 全文检索数据库

    #define Search using Lucene.Net.Analysis; using Lucene.Net.Analysis.Tokenattributes; using Lucene.Ne ...