[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
default-storage-engine=InnoDB
innodb-file-per-table=1
character_set_server=utf8mb4
skip-grant-tables
[mysqld_safe]
[client]
default-character-set=utf8mb4
[root@slave1 mysql]# service mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
在mysql 5.7之前,mysql数据库用户的密码的字段是password,5.7之后变成了authentication_string
mysql> update mysql.user set authentication_string=password(‘123456‘) where user=‘root‘ and host=‘localhost‘;
Query OK, 1 row affected, 1 warning (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> \q
注意一定要执行flush privileges;不然不会生效,重置完密码之后,要把my.cnf配置文件中的skip-grant-tables注释到
Linux环境下java开发环境搭建四 mysql密码忘记找回
原文:https://www.cnblogs.com/cplinux/p/10803162.html