linux登录myql报错:linux Access denied for user 'root'@'localhost' (using password: YES)

今天启动linux的mysql成功后,使用下面的命令登录:

mysql -u root -p

要求输入密码,输入密码但是报如下的错误:

linux Access denied for user 'root'@'localhost' (using password: YES)

 

找不到root的密码,想着能不能登录的时候不适用密码,解决方式如下:

1、先停止mysql 服务

service mysql stop

2、跳过密码验证:


[root@instance-f7npi0zx ~]# /usr/bin/mysqld_safe --skip-grant-tables

190619 15:52:21 mysqld_safe Logging to '/var/log/mysqld.log'.
190619 15:52:22 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
190619 15:52:23 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
证明成功

 

3、重启mysql

[root@instance-f7npi0zx ~]# service mysql start

4、不使用密码登录:

[root@instance-f7npi0zx ~]# mysql -u root 

mysql> 出现mysql 证明登录成功

5、设置新密码:

mysql> set password=password('123456');
Query OK, 0 rows affected (0.00 sec)

6、退出后重新登录

mysql> exit
Bye
[root@instance-f7npi0zx ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.25-log MySQL Community Server (GPL)

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值