转-解决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 ...
随机推荐
- HTML的DIV如何实现垂直居中
外部的DIV必须有如下代码 display:table-cell; vertical-align:middle; 这样可以保证里面的东西,无论是DIV还是文本都可以垂直居中
- win8系统 重装系统如何删除EFI分区
在PE下(一般重装系统就是在PE下),依次输入如下命令(注意虽然显示的是中文名"磁盘0",但是还是用英文disk 0) list disk select disk 0 clean
- #include<> 和 #include""的区别
#include< file >编译程序会先到标准函数库中找文件 #include”file” 编译程序会先从当前目录中找文件 参考原文 转: 在C程序中包含文件有以下两种方法: (1)用 ...
- Mapreduce运行过程分析(基于Hadoop2.4)——(三)
4.4 Reduce类 4.4.1 Reduce介绍 整完了Map,接下来就是Reduce了.YarnChild.main()->ReduceTask.run().ReduceTask.run方 ...
- 三. 200多万元得到的创业教训--创业并不须要app
摘要:有个点子,研发app或站点,推广,不断改进,探索盈利模式.这个通用的移动互联网创业流程.但我觉得.在某些特定的商业模式下,"研发app或站点"这步能够砍掉或推迟. 健生干货分 ...
- 开发Nodejs(rest框架)版本的百度新闻系统--开发环境配置
项目介绍:配置好开发环境,制作前端百度新闻界面,后台开发成Nodejs版本,做成做成rest风格API形式搭载mysql,使用Bootstrap搭建后台页面,完成对新闻的增删改查功能,利用Ajax配合 ...
- JavaGUI应用程序打包及数字签名
JavaGUI应用程序部署 JavaGUI程序发布分类: a.Applet:可以嵌入到浏览器中,通过网页的方式展示给用户 b.application :有两种发布方式 :打包成jar包通过bat的方式 ...
- properties文件读取配置信息
public static void main(String[] args){ String printerName=""; String path = "C:\\Bar ...
- 在myeclipse下面创建多层包
比如animal.cat.dog包 先创建animal包 然后创建animal.cat包 最后创建animal.cat.dog包 最后你发现这三个文件夹是分层的,层层嵌套的三个文件夹,而不是一个文件夹 ...
- Okapi BM25 (BM stands for Best Matching)
Okapi BM25 - Wikipedia https://en.wikipedia.org/wiki/Okapi_BM25 In information retrieval, Okapi BM25 ...