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 '密码';
相关推荐
大聪明-PLUS18 分钟前
如何使用 Docker 打包一个简单的应用程序:简易指南
linux·嵌入式·arm·smarc
serve the people2 小时前
Prompts for Chat Models in LangChain
java·linux·langchain
李昊哲小课2 小时前
Ubuntu 24.04 MariaDB 完整安装与配置文档
linux·ubuntu·mariadb
百***92023 小时前
【MySQL】MySQL库的操作
android·数据库·mysql
人间打气筒(Ada)4 小时前
zerotier内网穿透部署(rockylinux部署本地服务器)超详细~~~
linux·内网穿透·内网·公网·zerotier·穿透
心灵宝贝4 小时前
如何在 Mac 上安装 MySQL 8.0.20.dmg(从下载到使用全流程)
数据库·mysql·macos
想睡hhh4 小时前
mysql索引——理解索引机制及操作
mysql
剑动山河4 小时前
ubuntu 升级mysql由mysql5.7.42 升级到8.4.0
mysql·ubuntu·adb
Elias不吃糖4 小时前
Git常用指令合集
linux·git
_OP_CHEN4 小时前
Linux网络编程:(七)Vim 编辑器完全指南:从入门到精通的全方位实战教程
linux·运维·服务器·编辑器·vim·linux生态·linux软件