我的编程空间,编程开发者的网络收藏夹
学习永远不晚

Mysql 5.7 CentOS Access denied for user 'root'@'localhost'解决方式

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

Mysql 5.7 CentOS  Access denied for user 'root'@'localhost'解决方式

在centOS上安装完mysql, 登录MYSQL时遇到错误
[root@mysql-server Downloads]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

关键要用MYSQLD_OPTS="--skip-grant-tables"重新启动mysql服务
[root@mysql-server Downloads]# systemctl stop mysqld
[root@mysql-server Downloads]# systemctl set-enviroment MYSQLD_OPTS="--skip-grant-tables"
Unknown operation 'set-enviroment'.
[root@mysql-server Downloads]# systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
[root@mysql-server Downloads]# systemctl start mysqld
[root@mysql-server Downloads]# myslq -u root
bash: myslq: command not found...
Similar command is: 'mysql'
[root@mysql-server Downloads]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.06 sec)

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set authentication_string=password('root') where user = 'root';
Query OK, 1 row affected, 1 warning (0.07 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush previleges;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'previleges' at line 1
mysql> flush priviledges;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'priviledges' at line 1
mysql> flush privileges;
Query OK, 0 rows affected (0.11 sec)

mysql> quit
Bye
[root@mysql-server Downloads]# systemctl stop mysqld
[root@mysql-server Downloads]# systemctl unset-environment MYSQLD_OPTS
[root@mysql-server Downloads]# systemctl start mysqld
[root@mysql-server Downloads]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


参考:https://stackoverflow.com/questions/33510184/change-mysql-root-password-on-centos7

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

Mysql 5.7 CentOS Access denied for user 'root'@'localhost'解决方式

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

Mysql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES/NO)个人解决方法 分享一下

前言 Mysql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES/NO) 看了很多篇文章都没解决, 下面是我个人解决方法 分享一下 一、个人配置:系统w
2023-08-16

MySQL登录时出现ERROR 1045: Access denied for user ‘root‘@‘localhost‘ (using password: YES)无法打开解决方法汇总

目录一、Bug描述二、定位报错原因三、解决方案汇总方案一:重设密码(建议忘记密码才使用这个方案)步骤1:停止mysql服务步骤2:以无密码模式启动MySQL步骤3:连接Mysql步骤4:设置新密码步骤5:重启Mysql服务方案二:检查用户权
MySQL登录时出现ERROR 1045: Access denied for user ‘root‘@‘localhost‘ (using password: YES)无法打开解决方法汇总
2024-09-24

编程热搜

目录