CenOS 安装 mysql 临时密码 处理

数据库 版本 

Server version: 8.0.26 MySQL Community Server - GPL;官网下载的包  

wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz

 

安装 参考的这篇文章 Click Me

官方安装文档 

 

遇到的问题临时密码不好使

然后处理方式是 先修改让不用密码登录

1. 在 /etc/my.cnf 文件  的 [mysqld]下加入 skip-grant-tables

2. 保存 退出 重启mysql

3. 重新登录mysql  ./mysql -u root -p  不用密码也能进去

4. 操作修改密码

use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

 

执行修改密码报错。

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

 然后先执行

FLUSH PRIVILEGES;

 在执行修改密码就行了

5. 修改配置文件 /etc/mysql.cnf  的 [mysqld]下加入 skip-grant-tables 删除掉

6. 重启mysql 然后就可以用新密码登录了

 

参考链接

centos8安装mysql8并设置密码

修改mysql密码时遇见ERROR 1064 (42000) You have an error in your SQL syntax; check the manual that correspo

Mac修改密码

 

sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables

Mysql -u root

FLUSH PRIVILEGES;SET PASSWORD FOR root@'localhost' = PASSWORD('重新设置的密码');

mysql> set password for root@localhost = password('123456');ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds to your MySQL server version for the right syntax to use near 'password('123456')' at line 1


SET PASSWORD FOR root@localhost = '你重新设置的密码';

 

posted @ 2021-08-05 10:14  梨花大将  阅读(274)  评论(0编辑  收藏  举报