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. 什么是MySQL的事务?如何在Java中使用Connection接口管理事务?
数据库·mysql
Karoku0664 分钟前
【网站架构部署与优化】web服务与http协议
linux·运维·服务器·数据库·http·架构
geek_Chen016 分钟前
虚拟机共享文件夹开启后mnt/hgfs/下无sharefiles? --已解决
linux·运维·服务器
(⊙o⊙)~哦37 分钟前
linux 解压缩
linux·运维·服务器
牧小七2 小时前
Linux命令---查看端口是否被占用
linux
掘根2 小时前
【网络】高级IO——poll版本TCP服务器
网络·数据库·sql·网络协议·tcp/ip·mysql·网络安全
鸡鸭扣3 小时前
虚拟机:3、(待更)WSL2安装Ubuntu系统+实现GPU直通
linux·运维·ubuntu
友友马3 小时前
『 Linux 』HTTP(一)
linux·运维·服务器·网络·c++·tcp/ip·http
Bear on Toilet3 小时前
初写MySQL四张表:(3/4)
数据库·mysql
无妄啊______3 小时前
mysql笔记9(子查询)
数据库·笔记·mysql