centos7 修改mysql5.7密码
-
编辑mysql配置文件
$ sudo vi /etc/my.cnf [mysqld]下面添加 skip-grant-tables
-
重启mysql服务
$ sudo systemctl restart mysqld
-
无密码登录mysql
$ mysql
-
修改密码
mysql>update mysql.user set authentication_string=password('新密码') where user='root'; mysql>flush privileges; mysql>quit
-
编辑mysql配置文件
$ sudo vi /etc/my.cnf 注释skip-grant-tables # skip-grant-tables
-
重启mysql服务
$ sudo systemctl restart mysqld
-
测试
mysql -u root -p
创建用户
msyql>create user '用户'@'localhost' identified by '密码';