重置密码解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

 

一般这个错误是由密码错误引起,解决的办法自然就是重置密码。

假设我们使用的是root账户。

1.重置密码的第一步就是跳过MySQL的密码认证过程,方法如下:

#vim /etc/my.cnf(注:windows下修改的是my.ini)

在文档内搜索mysqld定位到[mysqld]文本段:
/mysqld(在vim编辑状态下直接输入该命令可搜索文本内容)

在[mysqld]后面任意一行添加“skip-grant-tables”用来跳过密码验证的过程,如下图所示:

保存文档并退出:

#:wq
2.接下来我们需要重启MySQL:

/etc/init.d/mysql restart(有些用户可能需要使用/etc/init.d/mysqld restart)

3.重启之后输入#mysql即可进入mysql。

4.接下来就是用sql来修改root的密码

mysql> use mysql;
mysql> update user set password=password("你的新密码") where user="root";
mysql> flush privileges;
mysql> quit

到这里root账户就已经重置成新的密码了。

5.编辑my.cnf,去掉刚才添加的内容,然后重启MySQL。大功告成!

网上有很多关于这个问题的解决说明,很多刚接触的朋友可能比较迷惑的是在自己的平台上找不到my.cnf或者my.ini文件,如果你是Linux,使用如下方式可以搜索到:

至于windows平台,去安装目录下找一下my.ini吧。

#####

cyx 20190319  pass

####

[root@10 mysql-data]# cp  /etc/my.cnf   /etc/my.cnf.bak

[root@10 mysql-data]# cat /etc/my.cnf

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

skip-grant-tables

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

# Settings user and group are ignored when systemd is used.

# If you need to run mysqld under a different user or group,

# customize your systemd unit file for mariadb according to the

# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]

log-error=/var/log/mariadb/mariadb.log

pid-file=/var/run/mariadb/mariadb.pid

#

# include all files from the config directory

#

!includedir /etc/my.cnf.d

[root@10 mysql-data]#

#systemctl restart mariadb

【转载】重置密码解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)的更多相关文章

  1. 重置密码解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

    出现报错: Warning: World-writable config file '/etc/my.cnf' is ignored // 该文件权限过高ERROR 1045 (28000): Acc ...

  2. 重置密码解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor

    一般这个错误是由密码错误引起,解决的办法自然就是重置密码. 假设我们使用的是root账户. 1.重置密码的第一步就是跳过MySQL的密码认证过程,方法如下: #vim /etc/my.cnf(注:wi ...

  3. 解决mysql登录报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)问题

    问题描述: 在ubuntu14.04上安装完MYSQL后,MYSQL默认给分配了一个默认密码,但当自己在终端上使用默认密码登录的时候,总会提示一个授权失败的错误. 报错信息:Access denied ...

  4. 重置密码解决MySQL for Linux错误 ERROR 1045 (28000)

    重置密码解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor ...

  5. mysql 链接失败(ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES))

    mysql链接失败(ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)) 修改: # ...

  6. Linux mysql 5.6: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    案例环境: 操作系统 :Red Hat Enterprise Linux Server release 5.7 (Tikanga) 64 bit 数据库版本 : Mysql 5.6.19 64 bit ...

  7. Ubuntu下MySQL报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

    在Ubuntu下 想要登录mysql数据库 root@JD:~# mysql -uroot -p 报错 ERROR 1045 (28000): Access denied for user 'root ...

  8. 在Linux下 MySQL错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 解决办法【很管用】

    一般这个错误是由密码错误引起,解决的办法自然就是重置密码. 假设我们使用的是root账户. 1.重置密码的第一步就是跳过MySQL的密码认证过程,方法如下: #vim /etc/my.cnf(注:wi ...

  9. MAC使用mysql报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

    遇到这种错误,需要重置密码. Step1:停止mysql,命令如下: $ sudo service mysql stop 或者是 $ sudo /usr/local/mysql/support-fil ...

随机推荐

  1. WPF项目中解决ConfigurationManager不能用(转)

    https://blog.csdn.net/MOESECSDN/article/details/78107888 在WPF项目中遇到这样的问题,做一下笔记.希望对自己和读者都有帮助. 在aap.con ...

  2. [蓝桥杯]ALGO-185.算法训练_Trash Removal

    题目描述: 代码如下: #include <algorithm> #include <cstdio> #include <cstdlib> #include < ...

  3. Windows配置ffmpeg

    一.ffmpeg简介 ffmpeg是一套可以用来记录.转换数字音频.视频,并能将其转化为流的开源计算机程序.采用LGPL或GPL许可证.它提供了录制.转换以及流化音视频的完整解决方案. 支持操作系统: ...

  4. finstrument-functions

    2017-12-03 23:59:16 参考 如何快速地在每个函数入口处加入相同的语句? https://www.zhihu.com/question/56132218 做个存档 scj@scjCom ...

  5. mongodb 安装使用备记

    # 1.1 安装 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931B ...

  6. DBsever工具连接mysql数据库

    当我们安装网DBeaver的时候,怎么通过这个工具来连接Mysql数据库呢 像这个地方就按平时你的数据库信息输入就可以了 接下来配置JDBC的内容 重点说一下驱动包的版本问题,因为我安装的mysql是 ...

  7. Android 开发 创建WiFi、WiFi热点 ---开发集合

    WIFI 权限 <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> < ...

  8. laravel中消息通知功能

    以laravel5.5为例子,这个功能laravel自带的有: 1.生成表文件的migration文件,再migrate一下在数据库里生成表.命令为:php artisan notifications ...

  9. Win32API标准模板

    #include<Windows.h> LRESULT CALLBACK WndProc //处理发送到窗口的消息的应用程序定义的函数.wndproc类型定义指向此回调函数的指针. //W ...

  10. playbook

    1 --- - hosts: web-server 3 remote_user: root tasks: - name: stop logstash shell: PID=` $PID &&a ...