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` = '%' WHERE `User` = 'root' LIMIT 1;
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'mysql'@'%' IDENTIFIED BY 'test' WITH GRANT OPTION;
方法一:
1.关闭mysql
# service mysqld stop
2.屏蔽权限
# mysqld_safe --skip-grant-table
屏幕出现: Starting demo from .....
3.新开起一个终端输入
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;//记得要这句话,否则如果关闭先前的终端,又会出现原来的错误
mysql> \q
mysql> use mysql
ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'mysql'
mysql> exit
Bye
[root@testtest ~]# service mysqld stop
Stopping mysqld: [ OK ]
[root@testtest ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking & [root@testtest ~]# mysql -u root -p -hlocalhost
Enter password: mysql> use mysql mysql> SELECT host,user,password,Grant_priv,Super_priv FROM mysql.user; mysql> UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root'; mysql> FLUSH PRIVILEGES; mysql> GRANT ALL ON *.* TO 'root'@'localhost'; mysql> GRANT ALL ON *.* TO 'root'@'cn.cn.cn.cn'; mysql> GRANT ALL ON *.* TO 'root'@'245.245.245.245'; mysql> GRANT ALL ON *.* TO 'root'@'127.0.0.1'; mysql> FLUSH PRIVILEGES; mysql> quit
Bye
[root@testtest ~]# service mysqld start
方法三:
skip-
grant
-tables
mysql> use mysql
ERROR 1044 (42000): Access denied
for
user
'root'
@
'localhost'
to
database
'mysql'
mysql> exit
Bye
[root@testtest ~]# service mysqld stop
Stopping mysqld: [ OK ]
[root@testtest ~]# mysqld_safe
--user=mysql --skip-grant-tables --skip-networking &
[root@testtest ~]# mysql -u root -p -hlocalhost
Enter
password
:
mysql> use mysql
mysql>
SELECT
host,
user
,
password
,Grant_priv,Super_priv
FROM
mysql.
user
;
mysql>
UPDATE
mysql.
user
SET
Grant_priv=
'Y'
, Super_priv=
'Y'
WHERE
User
=
'root'
;
mysql> FLUSH
PRIVILEGES
;
mysql>
GRANT
ALL
ON
*.*
TO
'root'
@
'localhost'
;
mysql>
GRANT
ALL
ON
*.*
TO
'root'
@
'cn.cn.cn.cn'
;
mysql>
GRANT
ALL
ON
*.*
TO
'root'
@
'245.245.245.245'
;
mysql>
GRANT
ALL
ON
*.*
TO
'root'
@
'127.0.0.1'
;
mysql> FLUSH
PRIVILEGES
;
mysql> quit
Bye
[root@testtest ~]# service mysqld start
mysql ERROR 1044 (42000): Access denied for user ''@'localhost' to database的更多相关文章
- 基于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. ...
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
提示:ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'.前两天也出现过这个问题,网上找了一个比 ...
- 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表里,存 ...
- mysql忘记root密码或报错:ERROR 1044 (42000): Access denied for user ”@’localhost’ to database ‘xx‘
有的时候忘记了root密码或其他用户的密码,登录的时候报错:ERROR 1044 (42000): Access denied for user ”@’localhost’ to database ' ...
- 一秒 解决 ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql 问题
提示:ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'.前两天也出现过这个问题,网上找了一个比 ...
- 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 ''@'localhost' to database 'db'
1.问题 在刚刚安装MySQL之后,进入到mysql环境下,创建数据库,出现下面的提示信息: ERROR 1044 (42000): Access denied for user ''@'localh ...
- error 1044 (42000):access denied for user ''@'localhost' to database 'quickapp' 解决方法
在虚拟机上重新创建一个数据库时,一直出现这个报错:error 1044 (42000):access denied for user ''@'localhost' to database 'quick ...
随机推荐
- css3 简单动画
<script> <!-- var x,y,n=0,ny=0,rotINT,rotYINT function rotateDIV() { x=document.getElementB ...
- DZY Loves Chemistry 分类: CF 比赛 图论 2015-08-08 15:51 3人阅读 评论(0) 收藏
DZY Loves Chemistry time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Linux/Unix里,ln -s
这是硬/软链接的命令ln -s 是创建软链接ln 是创建硬链接 你可以理解为:相当于windows下创建快捷方式一样,所以就不用太多解释了吧. ln -s /usr/lib/libX11.3 libX ...
- uva 10673 Play with Floor and Ceil
Problem APlay with Floor and CeilInput: standard inputOutput: standard outputTime Limit: 1 second Th ...
- 【Eclipse】安装subclipse的Eclipse插件
下载地址 subclipse subclipse Download and Install 一般来说,有两种方式:在线安装.离线包安装. 离线包安装 这里记录的是离线包的安装方式: 下载好离线包 He ...
- 复旦大学2014--2015学年第一学期(14级)高等代数I期末考试第七大题解答
七.(本题10分) 设 \(V\) 为数域 \(\mathbb{K}\) 上的 \(n\) 维线性空间, \(S=\{v_1,v_2,\cdots,v_m\}\) 为 \(V\) 中的向量组, 定义 ...
- C#操作oracle 到ExecuteNonQuery卡死不执行
方法1: 可能大家都解决了,我也遇到这个问题,c#更新卡住,但是plsql更新没问题.一直没找到答案,无意中想起,可能是oracle的表锁定了. 用下面的方法,顺利解锁保存了. SELECT /*+ ...
- 【leetcode❤python】 234. Palindrome Linked List
#-*- coding: UTF-8 -*-class Solution(object): def isPalindrome(self, head): ""&q ...
- BZOJ 3085: 反质数加强版SAPGAP (反素数搜索)
题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=3085 题意:求n(<=10^100)之内最大的反素数. 思路: 优化2: i ...
- [CF738D]Sea Battle(贪心)
题目链接:http://codeforces.com/contest/738/problem/D 题意:1*n的格子里有a条长为b的船.有一个人射了k发子弹都没打中船,现在问最少再打多少次一定能保证射 ...