centos7 修改mysql5.7密码

centos7 修改mysql5.7密码

  1. 编辑mysql配置文件

    复制代码
    $ sudo vi /etc/my.cnf
    [mysqld]下面添加
    skip-grant-tables
  2. 重启mysql服务

    $ sudo systemctl restart mysqld

  3. 无密码登录mysql

    复制代码
    $ mysql
  4. 修改密码

    复制代码
    mysql>update mysql.user set authentication_string=password('新密码') where user='root';
    mysql>flush privileges;
    mysql>quit
  5. 编辑mysql配置文件

    复制代码
    $ sudo vi /etc/my.cnf
     注释skip-grant-tables
    # skip-grant-tables
  6. 重启mysql服务

    复制代码
    $ sudo systemctl restart mysqld
  7. 测试

    复制代码
    mysql -u root -p

创建用户

复制代码
msyql>create user '用户'@'localhost' identified by '密码';
相关推荐
香蕉你个不拿拿^6 分钟前
Linux进程地址空间解析
linux·运维·服务器
人间打气筒(Ada)13 分钟前
Linux学习~日志文件参考
linux·运维·服务器·学习·日志·log·问题修复
xuhe21 小时前
Claude Code配合Astro + GitHub Pages:为 sharelatex-ce 打造现代化的开源项目宣传页
linux·git·docker·github·浏览器·overleaf
charlie1145141911 小时前
RK3568跑Arch Linux全路程指南(以正点原子的RK3568开发板为例子)
linux·嵌入式·rootfs·教程·环境配置·嵌入式linux·工程实践
爆米花byh2 小时前
在RockyLinux9环境的Doris单机版安装
linux·数据库·database
筱白爱学习3 小时前
RestHighLevelClient详细使用手册
linux·服务器·php
Moshow郑锴3 小时前
pgsql常见查询索引优化(等值条件+范围条件)
数据库·sql·mysql
若谷老师3 小时前
21.WSL中部署gnina分子对接程序ds
linux·人工智能·ubuntu·卷积神经网络·gnina·smina
zhangyueping83856 小时前
1、MYSQL-DDL
数据库·mysql
啊辉的科研6 小时前
植物单细胞RNA-seq分析教程3-2025年版
linux·r语言