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 '密码';
相关推荐
雪碧聊技术几秒前
centos7如何安装redis?
linux·centos·安装redis
Anthony_2317 分钟前
MySql常用SQL命令
服务器·数据库·sql·mysql·http·oracle·udp
旖旎夜光8 分钟前
linux(8)(下)
linux·学习
谢平康34 分钟前
通过nfs方式做目录限额方法
linux·服务器·网络
刘一说35 分钟前
Windows 与 Linux 跨平台自动化 MySQL 8 备份:专业级脚本设计与实战指南
linux·数据库·windows·mysql·自动化
I · T · LUCKYBOOM37 分钟前
2.2yum安装--单服务器托管多网站
linux·运维·服务器
郝学胜-神的一滴40 分钟前
线程同步:并行世界的秩序守护者
java·linux·开发语言·c++·程序人生
Linux技术芯1 小时前
浅谈nvme协议版本的发展
linux
释怀不想释怀1 小时前
Linux(复习常见命令)
linux·运维·服务器
_F_y1 小时前
负载均衡在线oj(文件版)
linux·运维·负载均衡