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 '密码';
相关推荐
yuanpan2 小时前
ubuntu系统上的conda虚拟环境导出方便下次安装
linux·ubuntu·conda
钢铁男儿3 小时前
Python 正则表达式(正则表达式和Python 语言)
python·mysql·正则表达式
AOwhisky3 小时前
Linux 文本处理三剑客:awk、grep、sed 完全指南
linux·运维·服务器·网络·云计算·运维开发
Gavin_9154 小时前
从零开始部署经典开源项目管理系统最新版redmine6-Linux Debian12
linux·ruby on rails·开源·debian·ruby·redmine
花小璇学linux4 小时前
imx6ull-驱动开发篇31——Linux异步通知
linux·驱动开发·嵌入式软件
shelutai4 小时前
ubuntu 编译ffmpeg6.1 增加drawtext,libx264,libx265等
linux·ubuntu·ffmpeg
runfarther4 小时前
搭建LLaMA-Factory环境
linux·运维·服务器·python·自然语言处理·ai编程·llama-factory
超级迅猛龙5 小时前
保姆级Debezium抽取SQL Server同步kafka
数据库·hadoop·mysql·sqlserver·kafka·linq·cdc
hello_ world.5 小时前
RHCA10NUMA
linux
神秘人X7075 小时前
Linux高效备份:rsync + inotify实时同步
linux·服务器·rsync