转-解决Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'问题
原因1-启动命令错误:
我开始的时候直接输入命令:mysql start
正确的启动命令是:
原因2-配置文件错误:
检查etc下面的my.cnf如下内容:
#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中的默认值)
这种问题需要强行重新修改密码,方法如下:
/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 才能执行。
| 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'); Now kill your running mysqld then restart it normally. sudo killall mysqld_safe& You should be good to go. Try not to forget your password again. |
MySQL Authentication Denial
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 ERROR 1045 (28000): Access denied for user 'root'@'localhost'问题的更多相关文章
- 解决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 ...
- ubuntu系统安装mysql登陆提示 解决Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'问题
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqoAAABtCAIAAADmldQYAAAe/0lEQVR4nO1dveslR3btzJGFk02GmU
- 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 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 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 'root'@'localhost' (using password: NO)的真正原因
在博客Linux mysql 5.6: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: N ...
- [mysql] ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).
用mysql -u root -p显示ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YE ...
- MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 的解决办法和原因
这两天下载了MySQL5.7.11进行安装,发现到了初次使用输入密码的时候,不管怎样都进不去,即使按照网上说的在mysqld 下面添加skip-grant-tables也是不行,后来研究了两天,终于找 ...
- MySQL5.7使用错误解决:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)【取消或重设root密码】
解决方法: 最简单方法: ⑴打开mysql中的my.ini(如果没有就将my-default.ini复制一份,并修改为my.ini): ⑵在[mysqld]下面空白行直接添加skip-grant-ta ...
随机推荐
- Mapreduce运行过程分析(基于Hadoop2.4)——(三)
4.4 Reduce类 4.4.1 Reduce介绍 整完了Map,接下来就是Reduce了.YarnChild.main()->ReduceTask.run().ReduceTask.run方 ...
- hi3531 SDK已编译文件系统制作jffs2文件系统镜像并解决这个问题 .
一, 安装SDK 1.Hi3531 SDK包位置 在"Hi3531_V100R001***/01.software/board"文件夹下,您能够看到一个 Hi3531_SDK_Vx ...
- js实现的美女瀑布流效果代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...
- woodcut
http://www.lintcode.com/en/problem/wood-cut/# 二分答案,贪心验证,具有单调性 class Solution { public: /** *@param L ...
- Xsolla和Hi-Rez工作室联手推行SMITE
视频游戏店面管理和计费解决方式的领导者,Xsolla.将重拳出击将与Hi-Rez游戏工作室合作.该工作室是一家美国的独立游戏开发商,主要开发MOBA游戏-SMITE. 支持全球600多种支付方式 Xs ...
- eclipse下对中文乱码问题的一些思考
一.浏览器问题 当你的html页面或jsp页面没有显式声明页面编码的时候,也就是没有下面其中之一的代码 <meta http-equiv="content-type" con ...
- Django初识二
1,在django中用于提交的form表单中的三要素: 1.1>form标签要有action和method,上传文件需要额外指定的enctype 1.2>获取用户输入的标签要有name属性 ...
- bzoj1486【HNOI2009】最小圈
1486: [HNOI2009]最小圈 Time Limit: 10 Sec Memory Limit: 64 MB Submit: 1778 Solved: 827 [Submit][Statu ...
- XMU 1615 刘备闯三国之三顾茅庐(三) 【欧拉函数+快速幂+欧拉定理】
1615: 刘备闯三国之三顾茅庐(三) Time Limit: 1000 MS Memory Limit: 128 MBSubmit: 45 Solved: 8[Submit][Status][W ...
- 如何完成dedecms外部数据库调用|跨数据库数据调用
第1步:打开网站include\taglib文件夹中找到sql.lib.php文件,并直接复制一些此文件出来,并把复制出来的这个文件重命名为mysql.lib.php. 注:mysql.lib.php ...