MySQL单实例
1. 跳过授权表登录
mysqld_safe --skip-grant-table --user=mysql &
2. 更改密码
mysql> update mysql.user set password=password('123456') where user='root' and host='localhost';
MySQL多实例
1. 跳过授权表登录 登录指定多实例的socket的文件
mysqld_safe --defaults-file=/data/3306/my.cnf --skip-grant-table --user=mysql &
mysql -S /data/3306/mysql.sock 登录数据库
2. 更改密码
mysql> update mysql.user set password=password('123456') where user='root' and host='localhost';
有疑问加站长微信联系(非本文作者)
