mysql远程连接
第一种:创建用户
mysql> insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));
mysql> flush privileges;
这样就创建了一个名为:test 密码为:1234 的用户。
注意:此处的"localhost",是指该用户只能在本地登录,不能在另外一台机器上远程登录。如果想远程登录的话,将"localhost"改为"%",也可以指定某台机器可以远程登录。
第二种:直接授权(推荐)
mysql>grant select,delete,update,create,drop on *.* to test@"%" identified by "1234";
mysql> flush privileges;
1.test用户对所有数据库都有select,delete,update,create,drop 权限。
2.@"%" 表示对所有非本地主机授权,不包括localhost。
3.对localhost授权:加上一句grant all privileges on testDB.* to test@localhost identified by '1234';即可。