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 @   梨花大将  阅读(303)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示