首先先把mysql服务关闭
service mysqld stop
然后输入 重置root密码
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
设置root密码
UPDATE user SET PASSWORD=PASSWORD('root') where USER='root';FLUSH PRIVILEGES;
添加远程登录用户
grant all privileges on *.* to 'pigs'@'%' identified by 'pigsroot' with grant option;
禁用root远程登录
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
连接测试
mysql -upigs -p