- 检查mysql服务是否启动,如果启动,关闭mysql服务
service mysql stop
- 修改mysql的配置文件my.cnf
my.cnf配置文件的位置,一般在/etc/my.cnf,有些版本在/etc/mysql/my.cnf
在配置文件中,增加2行代码
[mysqld]
skip-grant-tables
- 修改密码
连接mysql这个数据库,修改用户密码
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update mysql.user set authentication_string