Mysql远程登陆方法

时间:2021-02-13 16:07:47

改表法

x:\>mysql -u root -pvmware

mysql> use mysql;
mysql> update user set host = ‘%’ where user = ‘root’;
mysql> select host, user from user;

mysql> flush privileges;

授权法

mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword’ WITH GRANT OPTION;

注:一:myuser使用mypassword从任何主机连接到mysql服务器;

二:允许用户myuserip192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码;