LINUX篇,设置MYSQL远程访问实用版

每次设置root和远程访问都容易出现问题, 总结了个通用方法, 关键在于实用

 

用一个session 打开

# /etc/init.d/mysql stop  
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &  

 

用另一个session打开

 

# mysql -u root mysql  

mysql> Grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option; //增加远程访问权限
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;  //增加root密码
mysql> FLUSH PRIVILEGES;  
mysql> quit  
# /etc/init.d/mysql restart  
# mysql -uroot -p  
Enter password: <输入新设的密码newpassword>  
mysql>  UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;  //再次修改root密码

 mysql> FLUSH PRIVILEGES;  
mysql> quit  
# /etc/init.d/mysql restart  

 

一般搞定

 

 

你可能感兴趣的:(linux)