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 '密码';
相关推荐
XP62267 分钟前
MySQL 数据库连接数查询、配置
数据库·mysql
之歆11 分钟前
MySQL 主从复制完全指南
android·mysql·adb
zsyf19871 小时前
MySQL如何执行.sql 文件:详细教学指南
数据库·mysql
daad7771 小时前
schedule_fair
linux
盟接之桥2 小时前
制造业EDI数字化:连接全球供应链的桥梁
linux·运维·服务器·网络·人工智能·制造
一点多余.2 小时前
openGauss 企业版安装全流程指南
linux·数据库·opengauss·企业版
XiaoHu02072 小时前
Linux网络编程(第四弹)
linux·网络·智能路由器
金刚猿2 小时前
03_虚拟机中间件部署_Nacos 部署单机模式、配置鉴权
linux·中间件·nacos·配置鉴权
发现你走远了3 小时前
MySQL(Windows)压缩包安装与配置指南(超详细版)
数据库·mysql