开启 MySQL 远程访问权限:在linux系统上登陆mysql服务。
-- root 是用户名[root@localhost ~]# mysql-u root-p
Enter password: -- 输入密码
创建远程连接 MySQL 的用户:
-- 创建用户、密码及权限范围 第一个 roo t为用户名 @后为适用的主机,‘%’表示所有电脑都可以访问连接,第二个 root 为密码mysql>GRANTALLPRIVILEGESON*.*TO'root'@'192.168.0.2'IDENTIFIEDBY'root'WITHGRANTOPTION;
Query OK, 0rows affected (1.57 sec)
-- 立即生效mysql>flushprivileges;
Query OK, 0rows affected (0.00sec)
注:如果执行是报以下错误
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
尝试
flush privileges
一下或许就OK了
网友评论