linux连接mysql 出现Access denied for user 'root'@'localhost'(using password: YES)错误解决方案

时间:2022-08-23 19:44:00

linux连接mysql /usr/local/mysql/bin/mysql -uroot -p

输入密码出现Access denied for user 'root'@'localhost'(using password: YES)错误。

解决办法:

1.先停止mysql 服务

service mysqld stop

linux连接mysql 出现Access denied for user 'root'@'localhost'(using password: YES)错误解决方案

2.进入mysql安装目录bin/ 使用safe模式,进行重启:

./mysqld_safe --skip-grant-tables

linux连接mysql 出现Access denied for user 'root'@'localhost'(using password: YES)错误解决方案

3.新开一个终端,使用root账户,无密码登录,修改root用户密码

/usr/local/mysql/bin/mysql -uroot

use mysql
update user set password=PASSWORD("你的密码") where User = 'root';
5.7版本下的mysql数据库下已经没有password这个字段了,password字段改成了authentication_string
update user set authentication_string=PASSWORD("你的密码") where User = 'root';

4.重启mysql,正常登录

service mysqld restart  重启

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhwAAAA7CAYAAAAwyFPbAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAA2jSURBVHhe7Z1tkuO4DYbnPHMVXyROpSqp3WSz2fntg/gcc7gOQREiCAIgpZa6rem3pp6aFj8B0hJeURb97cePH2/fvn27DrfH28+fPxeed7sM2M/3+9vzccvj/Lx/t8sAAAAAW7EEx/f7swT159v9e5v3qVAwFDbdHj/fHrf690fZS30dHYy32L+//9vbo4g1t34RHPQZ4LG9GmfMzxWo5+2M/+WzANEOAPgoPMHxWRfs+/PxdjPSic4udRd+f76YQNrIR9kfzi+tIF1ccHx15s/fJDpeTHBE5/8RnN0+ACBgi+C4P+vdE5VZ7qbaE5jLWHlhfl69kHkLMujdHhyQ7Tv1HLBvsp0+gEf2jfyraf4dZNN+sue54YI+sj/qn/MeD/HIyRh/LmvZv6yyKDYGpNB/Pceq7Wj8pW3ZduPR2sz8ND6meo3IG9jnwvVSW8vnMtm82lfmYG279rfaK/oZfX5k/uNmr1J486v9y/VnfU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edqVwojZO/XACAAD4UH71azoEh8BdQTiAvI8Gt53oVm9G5FUTXvXASgUAAPxq1JtK4wnCpamr+K7giL80CgAAAABwANFrsQAAAAAAh/A7BAc4gtE/qw4AAICvw38gOMARRKICggMAAID8LRUAdgPBAQAAIOK/VxMccj+Kg98yAQnejGzrq70QHAAAACIswfGyr+00r422234vr6R+jL16R9Aj2GL//v4nXlsqgoM+A5te64XgAAAAEGE9UvnMjUmi3x/p7FJ34Xrr8qvxUfaH80srSBAcAAAAjsb60qgXkHjTLMqjMssqSCsQmo21jE2r3Pxmq/CKDHr1d0TsO/UcsG+ynT6AR/aN/Ktp/gpB0z5tnb7hsc/I/qh/zns85Bbo/fhzWcv+ZZVFMWs/BAcAAIAIax8OLyBl+DsUHIjSMYsCCrZNPSorAtYofyljB0mCBQcFxtxnqi/bW4K9CNJZxNT2ZvrPaY5/jDc+Oj0HcN1+wMh+JupfC6QZOxvKmG7+GXwIDgAAABHW1uYzAalLL8/+dfoauEb55XhGcKyPHpQtFLAtcZDTJvt3/RP441NXXhZ8XyxC+1Wa1X9X1vHFt7/mQXAAAAA4lH/8dT3BkdvioN6soPRBcg3CHyI4FKmtbSscgf0qzeq/K7tJcGixtDDlJwHBAQAAIOLvfx4kOBJ9wExBLBQEbX5XhgL2xCMCJj+SkO1lYVLrz/T/HsHRtU/2GyLHY2Q/4/VP6UescFAbkfAzgeAAAAAQcf9jVnDYd8BNgJMrD3vyiSwyOF8FvU5A1Pr8WunjUb9Y2X1pNOx/5J+dL23MgsHJGzG2P+6f5ozTss1iHPVcRoKDV3wgOAAAABzK36YFx2sgA+uW1QNQGQsOY+VnBAQHAACACG+FYwnqaoUAXJy6SnK4oITgAAAA4PLt7f80R7xasFaQIAAAAABJRU5ErkJggg==" alt="" />

/usr/local/mysql/bin/mysql -uroot -p  然后输入刚才重置的密码

linux连接mysql 出现Access denied for user 'root'@'localhost'(using password: YES)错误解决方案

完成,连接成功!

linux连接mysql 出现Access denied for user 'root'@'localhost'(using password: YES)错误解决方案的更多相关文章

  1. MySQL 出现 Access denied for user 'root'@'localhost' (using password: YES) 错误

    登录某台服务器的mysql时候总报错: mysql2/client.rb:58:in `connect': Access denied for user 'root'@'localhost' (usi ...

  2. Web项目打成war包部署到tomcat时报MySQL Access denied for user 'root'@'localhost' (using password: YES)错误解决方案

    Web项目使用使用root账号root密码进行部署,通过Eclipse加载到Tomcat服务器可以发布成功,打成war包放到tomcat的webapps目录无法发布成功,报错: jdbc.proper ...

  3. mariadb mysql 报'Access denied for user 'root'@'localhost' (using password: NO)'错误的解决

    C:\Program Files\MariaDB 10.2\bin>mysql admin -u root password "x123456789" mysql Ver 1 ...

  4. linux下mysql出现Access denied for user 'root'@'localhost' (using password: YES)解决方法

    # /etc/init.d/mysql stop # mysqld_safe --user=mysql --skip-grant-tables --skip-networking & # my ...

  5. mysql中Access denied for user 'root'@'localhost' (using password:YES)错误

    此错误主要是由于你的系统曾经装过MYSQL,在重装就会要求输入原来设定的密码    由于输入错误导致    解决办法见 上一篇博客   MYSQL安装时解决要输入current root passwo ...

  6. Windows系统下MySQL数据库出现Access denied for user 'root'@'localhost' (using password:YES) 错误

    Windows系统下MySQL数据库出现Access denied for user 'root'@'localhost' (using password:YES) 错误,(root密码错误) 处理方 ...

  7. mysql登录:access denied for user 'root'@'localhost'(using password:YES)

    mysql登录: access denied for user 'root'@'localhost'(using password:YES) 解决: use mysql; select user,ho ...

  8. MySQL出现Access denied for user ‘root’@’localhost’ (using password:YES)

    连接时MySQL出现了下面的错误: Access denied for user ‘root’@’localhost’ (using password:YES) 解决的办法是先停止MySQL服务,在m ...

  9. 安装mysql因为/tmp权限不足而导致ERROR 1045 (28000): Access denied for user root@localhost (using password: NO)的解决方案

    本机是centos 6.5  安装的mysql是5.1的版本. 在安装mysql之后,第一次启动mysql服务的时候,需要/tmp有777(rwxrwxrwx)的权限,然而楼主的/tmp是755(rw ...

随机推荐

  1. C语言学习019:函数指针

    在C语言中,函数名也是指针变量,比如创建了一个add(int n,int m)的函数的同时也创建了一个名为add的指针变量,因此我们可以把函数指针当作一种类型为它赋值.当作参数传递等操作 C语言创建函 ...

  2. EF性能调优

    首先说明下: 第一次运行真是太慢了,处理9600多个员工数据,用了81分钟!! 代码也挺简单,主要是得到数据-->对比分析-->插入分析结果到数据库.用的是EF的操作模式. public ...

  3. JS的Document属性和方法小结

    Document想必大家并不陌生吧,在使用js的过程中会经常遇到它,那么它有哪些属性.哪些方法,在本文将以示例为大家详细介绍下,希望对大家有所帮助 document.title //设置文档标题等价于 ...

  4. 项目中oracle存储过程记录——经常使用语法备忘

    项目中oracle存储过程记录--经常使用语法备忘 项目中须要写一个oracle存储过程,需求是收集一个复杂查询的内容(涉及到多张表),然后把符合条件的记录插入到目标表中.当中原表之中的一个的日期字段 ...

  5. Java 数组基础,java.util.Arrays

    定义数组 方式1(推荐,更能表明数组类型) 方式2(同C语言) 方式3定义时直接初始化 数组运用基础 数组长度 equals() 数组元素不为基本数据类型时 二维数组 二维数组基础 变长的二维数组 j ...

  6. git切换分支

    今天同事问我她的报错了,我看了一下,是分支没有指向远程仓库对应的分支;报错如下; $ git pull There is no tracking information for the current ...

  7. 微信小程序中的app.js-清除缓存

    微信小程序中的app.js 关于小程序app.js生命周期的介绍 App(Object) App() 函数用来注册一个小程序.接受一个 Object 参数,其指定小程序的生命周期回调等. App() ...

  8. 【noip 2012】提高组Day2T3.疫情控制

    Description H国有n个城市,这n个城市用n-1条双向道路相互连通构成一棵树,1号城市是首都,也是树中的根节点. H国的首都爆发了一种危害性极高的传染病.当局为了控制疫情,不让疫情扩散到边境 ...

  9. spring模拟ioc

    非spring 开发 public class UserService { private UserDao userDao=new UserDaoImpl(); public void addUser ...

  10. java提高篇之详解内部类

    可以将一个类的定义放在另一个类的定义内部,这就是内部类. 内部类是一个非常有用的特性但又比较难理解使用的特性(鄙人到现在都没有怎么使用过内部类,对内部类也只是略知一二). 第一次见面 内部类我们从外面 ...