原文http://www.cnblogs.com/khler/archive/2011/02/10/1950819.html
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Red Hat Enterprise Linux 5服务器上mysql启动报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
原因1-启动命令错误:
我开始的时候直接输入命令:mysql start
正确的启动命令是:
/etc/rc.d/init.d/mysql start
原因2-配置文件错误:
检查etc下面的my.cnf如下内容:
[client]
#password = your_password
port = 3306
socket = /usr/mysql-data/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /usr/mysql-data/mysql.sock
原因3-启动文件错误:
需要修改MySQL启动脚本/etc/rc.d/init.d/mysql,
其中datadir= ? 一行检查下!
原因4-前提是你在使用php连接时候报错!
在/etc/php.ini修改mysql.default_socket的值设置为:
mysql.default_socket=/var/lib/mysql/mysql.sock
回到终点设置个连接:ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
(在/etc/php.ini中mysql.default_socket这个文件中,关于mysql.default_socket的值的说明是这样的,
;Default socket name for local MySQL connects. If empty, uses the built-in MySQL defaults.
这个值一开始是空的,也就是说,如果我们不主动去修改的话,php将会使用内建在mysql中的默认值)
另一篇文章:
Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'问题的解决
这种问题需要强行重新修改密码,方法如下:
/etc/init.d/mysql stop (service mysqld stop )
/usr/bin/mysqld_safe --skip-grant-tables
另外开个SSH连接
[root@localhost ~]# mysql
mysql>use mysql
mysql>update user set password=password("123456") where user="root";
mysql>flush privileges;
mysql>exit
pkill -KILL -t pts/0 可将pts为0的**用户(之前运行mysqld_safe的用户窗口)强制踢出
正常启动 MySQL:/etc/init.d/mysql start (service mysqld start)
注意:另外还遇到需要service mysql star才能启动service mysql stop才能停止。
还有直接使用mysql不能找到命令,错误为“bash: mysql: command not found”可以直接**mysql的安装目录中的bin文件夹跟绝对路径运行命令,还有的需要加./mysql 才能执行。
本文来自:http://sundful.javaeye.com/blog/704337
另一篇关于清除密码、重置用户的文章:
Quote:
First things first. Log in as root and stop the mysql daemon.
sudo /etc/init.d/mysql stop
Now lets start up the mysql daemon and skip the grant tables which store the passwords.
sudo mysqld_safe --skip-grant-tables&
(press Ctrl+C now to disown the process and start typing commands again)
You should see mysqld start up successfully. If not, well you have bigger issues. Now you should be able to connect to mysql without a password.
sudo mysql --user=root mysql
update user set Password=PASSWORD('new-password');
flush privileges;
exit;
Now kill your running mysqld then restart it normally.
sudo killall mysqld_safe&
(press Ctrl+C now to disown the process and start typing commands again)
/etc/init.d/mysql start
You should be good to go. Try not to forget your password again.
http://www.howtoforge.com/reset-forgotten-mysql-root-password
另外关于denied的总结:
MySQL Authentication Denial
3/29/2005, 12:05 am
It seems to me that a lot of people have auth denial when trying to make connections to MySQL. They seem to ignore the text of the error message. ‘Access Denied’ means access denied, nothing else.
Remember three things have to match. The host as MySQL sees it, the username, and the password. When MySQL returns access denied it’s not broken. One or more of those three things does not match. I don’t really need to reiterate what’s in the manual. Chang the lock or change the key to make it fit.
其中连接到mysql的文档内容为:
http://dev.mysql.com/doc/refman/5.5/en/access-denied.html
分享到:
相关推荐
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 解决: 1.打开在创建mysql容器时挂载的conf目录下的mysqld.cnf(如下文件) 我创建docker的姿势 2.进入mysqlId.cnf文件中在...
首先是不知道怎么忽然mysql用命令行,workbench都登录不了,都提示’Access denied for user ‘root’@’localhost’。 数据库卸载重装了几次都不行。好像感觉数据清理不干净。解决的过程遇到的坑,这里记录分享下。...
MySQL密码忘了,可以进行重置设置。安全模式的进入,操作。
前言 最近学习linux,然后将win换成了ubuntu。之前安装的mysql也不能用了,现在将在ubuntu18.0.4上安装mysql并将...登录时出现ERROR 1698 (28000): Access denied for user ‘root’@‘localhost’。这应该时我们之前
Unhandled rejection SequelizeAccessDeniedError: Access denied for user 'lupeng'@'localhost' (using password: YES) 这是Node在使用Sequlize连接Mysql数据时报的错,关键看冒号后面的错误:访问拒绝,关键是...
ERROR 1044 (42000): Access denied for user ”@’localhost’ to database ‘python’ 2. 解决方法: 执行以下命令进入控制台: mysql –user=root -p 输入root用户的密码即可进入mysql控制台: 创建数据库: ...
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO) 第一步:编辑mysql安装目录中的配置文件my.ini,在[mysqld]这个条目下加入 skip-grant-tables 如下图: 保存退出后 第二...
MySQL ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO) 的解决办法和原因 这两天下载了MySQL5.7.11进行安装,发现到了初次使用输入密码的时候,不管怎样都进不去,即使...
主要介绍了Linux下数据库报ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)实用解决方案,希望能对大家有帮助。
昨天连数据库没有问题,但是今天连接数据库就报这个错误了,网上也搜了不少的方法,有一个方法解决了我的问题。我的环境是Linux 步骤:首先需要跳过密码认证,在Linux环境中找到/etc/my.cnf文件,在文件中找到...
主要介绍了ubuntu18.0.4安装mysql并解决ERROR 1698 (28000): Access denied for user 'root'@'localhost',现在将ubuntu18.0.4上安装mysql并将碰到的问题记录下来,感兴趣的朋友一起看看吧
新装MySQL后,首次执行 mysql -uroot -p 后会发现root密码不为空,要重置root密码请参考以下步骤。...这时候在cmd里面输入mysql -u root -p就可以不用密码登录了,出现password:的时候直接回车可以进入,不会出现ERROR
解决办法 1.打开/etc/mysql/debian.cnf文件,修改其只读属性 chmod 777 debian.cnf 可以看到里面存储了系统管理员的密码。 ...mysql -udebian-sys-maint -p ...3.进入控制台后....mysql -u root -p Go· again
主要介绍了mysql登录错误:'Access denied for user 'root'@'localhost',本文给出了操作过程及注意事项,需要的朋友可以参考下
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) 提示的是用户访问被拒绝,原因是密码不正确,但是我们明明配置的是正确的密码,原因就在yml中: spring: datasource: ...
主要给大家介绍了如何解决mysql在创建数据库后出现:Access denied for user 'root'@'%' to database 'xxx'的错误提示,文中介绍的非常详细,需要的朋友可以参考借鉴,下面来一起看看吧。
主要介绍了MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 的原因分解决办法的相关资料,需要的朋友可以参考下
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) mysql版本为:Ver 14.14 Distrib 5.7.10, for Linux(X86_64) using EditLine wrapper 然而实际上并没有进行过root密码设置...
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES) 解决方法: 1、在启动mysql的参数中加入跳过密码问题方式,如下: vim /etc/my.cnf 并在[mysql]下面加上skip-grant-...
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 网上的答案是各种各样的,最终解决问题的方法总结为以下,好多都是没有设置初始密码造成此问题的。 解决方法如下: [root@...