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
mysql ERROR 1045 (28000): Access denied for user 可能解决方法分析的更多相关文章
- 【MySQL】ERROR 1045 (28000): Access denied for user的解决方法
去官网下载压缩版的MySQL Server,解压配置path环境变量后.然后克隆my-default.ini创建my.ini文件,在文件中[mysqld]下面配置basedir和datadir bas ...
- 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 ...
- 【技术贴】解决Mysql ERROR 1045 (28000): Access denied for
今天Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' 肯定是密码不对了.那么重置一下密码吧. 打开 cmd 输入以 ...
- 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 ...
- 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 ...
- 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 ...
- MySql ERROR 1045 (28000): Access denied 错误
[MySql ERROR 1045 (28000): Access denied 错误] 即登陆错误,使用MySql登陆时,需使正确的username/passwd.通过 -u -p 参数即可. My ...
- 解决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 ...
- 转-解决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 ...
随机推荐
- 30. Child Labor Problem and Its Solution 童工问题及解决方法
30. Child Labor Problem and Its Solution 童工问题及解决方法 ① Over a hundred years ago,Charles Dickens shocke ...
- C语言之预处理命令与用typedef命名已有类型
预处理命令 主要是改进程序设计环境,以提高编程效率,不属于c语言本身的组成部分,不能直接对它们进行编译,必须在对 程序编译之前,先对程序中的这些特殊命令进行“预处理”.比如头文件. 有以下三类:宏定义 ...
- Shiro 登录页面的几个固定字段
http://shiro.apache.org/webapp-tutorial.html Step 3b: Add a login page Since Step 3a enabled login a ...
- ArcGIS根据最大最小坐标换算瓦片行列号
1.前言 在上一节中我们知道了屏幕上一像素等于实际中多少单位长度(米或经纬度)的换算方法,而知道这个原理后,接下来我们要怎么用它呢?它和我们前端显示地图有什么关联呢?这一节,我会尽量详细的将这两个问题 ...
- noip第10课作业
1. 统计不同类型字符出现次数 [问题描述] 输入一个字符串(假设长度不超过1000个字符),统计其中大写,小写,数字,其他字符出现的次数. [样例输入]Hello,what are you ...
- 检测Linux服务器端口是否开通
现如今云服务器已经是大势所趋,国内比较著名的云服务器厂商有阿里.腾讯,国外有aws,尽管有的公司目前为止还是使用的物理机,但是无论你是使用的云服务器还是物理机,在运行服务时都必不可少的需要监听到指定的 ...
- radom
radom模块提供了随机生成对象的方法 Help on module random: NAME random - Random variable generators. FILE /usr/local ...
- c++ 日志输出库 spdlog 简介(4)- 多线程txt输出日志
在上一节的代码中加入了向文本文件中写入日志的代码: UINT CMFCApplication1Dlg::Thread1(LPVOID pParam) { try{ size_t q_size = ; ...
- .NET Core MemoryCache缓存获取全部缓存键
在Core中不能使用原HttpRuntime.Cache缓存,改为MemoryCache(Microsoft.Extensions.Caching.Memory). 现MemoryCache新版为2. ...
- Sql语句在SqlServer中创建数据库、表格并添加约束
通过Sql语句来创建数据库与架构 创建数据库 数据库的创建首先是要引用主数据库的,需要在master数据库的环境下进行创建.大致的语法如下: -- 使用master数据库 use master -- ...