mysql重置密码和mysql error 1044(42000)错误
#mysql错误:(密码不正确,需要重置密码)
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
#编辑配置文件
[root@m1 mysql]# vi /roobo/server/mysql/my.cnf
[mysqld]
skip-grant-tables
#修改完后重启服务
[root@m1 mysql]# /etc/init.d/mysqld restart
#登录数据库
[root@m1 mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.24-log Source distribution
Copyright (c) 2000, 2015, 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>
mysql> use mysql;
mysql> update user set password=password("你的新密码") where user="root";
mysql> flush privileges;
mysql> quit
#再把vi my.cnf 配置文件中下面参数删除。
[mysqld]
skip-grant-tables
#修改完后重启服务
[root@m1 mysql]# /etc/init.d/mysqld restart
#再用设置的密码登录
mysql -uroot -p
passwd:******
mysql error 1044(42000)错误
[root@m1 ~]# mysql -uroot -p
Enter password:
ERROR 1049 (42000): Unknown database '127.0.0.1'
[root@m1 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.6.24-log Source distribution
Copyright (c) 2000, 2015, 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> grant all on work.* to work@'192.168.1.4' identified by 'juan3652014';
ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'work'
原因: 授权需要WITH GRANT OPTION 才能授权,否则会报。
mysql> show grants for root@'localhost';
+----------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost |
+----------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*F109C974766912D490ECD7E3C8754542FC773A49' |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION
+----------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
解决方法:
#登录mysql
mysql -uroot -p -h 127.0.0.1
mysql> use mysql
Database changed
mysql> select user,host from user;
+--------+-------------+
| user | host |
+--------+-------------+
| root | 127.0.0.1 |
| rep | 192.168.1.% |
| work | 192.168.1.4 |
| root | localhost |
| zabbix | localhost |
+--------+-------------+
5 rows in set (0.00 sec)
#授权成功
grant all on work.* to work@'192.168.1.4' identified by 'juan3652014';
flush privileges;
如上所示,root@localhost账号没有WITH GRANT OPTION选项,关于WITH GRANT OPTION选项,如果想让授权的用户,也可以将这些权限授予给其他用户,需要选项 “WITH GRANT OPTION“ 。也就是说有这个选项就可以将权限传递给第三方。这也是上面root@localhost用户给其它用后授权报错的原因,如果以 root@127.0.0.1登录(此账号拥有WITHGRANT OPTION选项),创建用户并授权就不会有这个错误。
mysql重置密码和mysql error 1044(42000)错误的更多相关文章
- Mysql re-set password, mysql set encode utf8 mysql重置密码,mysql设置存储编码格式
There is a link about how to re-set password. http://database.51cto.com/art/201010/229528.htm words ...
- mysql忘记root密码或报错:ERROR 1044 (42000): Access denied for user ”@’localhost’ to database ‘xx‘
有的时候忘记了root密码或其他用户的密码,登录的时候报错:ERROR 1044 (42000): Access denied for user ”@’localhost’ to database ' ...
- mysql ERROR 1044 (42000): Access denied for user ''@'localhost' to database
新安装的mysql密码是空的. ./mysql -u root -p use mysql SELECT `Host`,`User` FROM user; UPDATE user SET `Host` ...
- MySQL:ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'. 原因是:mysql数据库的user表里,存 ...
- centos mysql数据库问题:ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'(转)
问题描述: 安装好数据库MySQL,进入mysql,设置号密码后,退出的时候,利用密码无法进入,直接回车后可进入,无法看到数据库mysql,use mysql返回错误:ERROR 1044 (4200 ...
- 解决 ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
原文链接:https://blog.csdn.net/sea_snow/article/details/82498791 感谢原作者大大 提示:ERROR 1044 (42000): Access ...
- ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'mysql'
mysql> use mysqlERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'mysql' ...
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
提示:ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'.前两天也出现过这个问题,网上找了一个比 ...
- 基于mysql创建库的报错解决小记mysql ERROR 1044 (42000): Access denied for user ''@'localhost' to database
mysql ERROR 1044 (42000): Access denied for user ''@'localhost' to database异常处理 1.找到find / -name my. ...
随机推荐
- connect-falsh的用法
借鉴博客 http://yunkus.com/connect-flash-usage/
- Redis实现分布式锁 php
一.分布式锁的作用: redis写入时不带锁定功能,为防止多个进程同时进行一个操作,出现意想不到的结果,so...对缓存进行插入更新操作时自定义加锁功能. 二.Redis的NX后缀命令 Redis有一 ...
- AC日记——[LNOI2014]LCA bzoj 3626
3626 思路: 离线操作+树剖: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 100005 #defin ...
- 解决网页中Waiting (TTFB)数据加载过慢的问题
解决网页中Waiting (TTFB)数据加载过慢的问题 最近做了一个网页,在本地测试良好,数据可以得到很快的反馈,但是当部署到云端Linux上时候,就会出现加载缓慢的问题.本地测试,得到数据大概3s ...
- CentOS7英文环境下使用中文输入法
一般我们使用英文环境是没有办法使用中文的,这是因为我们没有设置在英文环境下的中文配置,下面我们在英文环境下配置中文输入法ibus使得我们可以输入中文. 首先,安装ibus(centos6以后已经默认安 ...
- IllegalStateException: Unable to find a @SpringBootConfiguration
此处需要改掉包名和类名
- ESLint 使用入门
在团队协作中,为避免低级 Bug.产出风格统一的代码,会预先制定编码规范.使用 Lint 工具和代码风格检测工具,则可以辅助编码规范执行,有效控制代码质量. 在以前的项目中,我们选择 JSHint 和 ...
- 深入解析php中的foreach问题
本篇文章是对php中的foreach问题进行了详细的分析介绍,需要的朋友参考下 前言:php4中引入了foreach结构,这是一种遍历数组的简单方式.相比传统的for循环,foreach能够更加便 ...
- Bzoj3197/洛谷3296 [SDOI2013]刺客信条assassin(树的重心+树Hash+树形DP+KM)
题面 Bzoj 洛谷 题解 (除了代码均摘自喻队的博客,可是他退役了) 首先固定一棵树,枚举另一棵树,显然另一棵树只有与这棵树同构才有可能产生贡献 如果固定的树以重心为根,那么另一棵树最多就只有重心为 ...
- [BZOJ4815][CQOI2017]小Q的表格(莫比乌斯反演)
4815: [Cqoi2017]小Q的表格 Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 832 Solved: 342[Submit][Statu ...