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 '密码';
相关推荐
修己xj7 小时前
nslookup 使用指南:两种模式与常用查询技巧
linux
唠玖馆9 小时前
文件系统详解
linux·文件系统·ext2
GeW10 小时前
当Linux内核开始“确定性”,制造高端化才有了底层语法
linux
这个DBA有点耶11 小时前
函数索引的“完全一致”有多苛刻:写法、字符集、类型,差一处就失效
数据库·mysql·代码规范
星恒随风11 小时前
MySQL 从零入门(三):表的约束详解
linux·服务器·数据库·笔记·mysql
StarsGreen13 小时前
libva在intel平台上的前端流程简介
linux
坤坤子吖16 小时前
Linux网络编程:自定义应用层协议与 JSON 序列化
linux·服务器·网络·c++·笔记·json
Felven18 小时前
华为鲲鹏920s芯片serdestool工具使用说明
linux·运维·服务器·华为·鲲鹏920·serdestool
莫晓燚18 小时前
mall 电商项目完整部署---实战
linux·运维·docker·容器
咋的啥名都用不了呢~18 小时前
Linux项目部署5(安装Nginx的插件)
linux