系统是64位Windows 7,MySQL版本为5.1。数据库服务器装在局域网中的另一台机器上,ip是:192.168.0.101。想通过另一台机器(ip为192.168.0.100)远程连接101,于是在101上执行这句:grant all privieleges on dbsrv.* to 'root' @ '%'; 结果返回这个错误:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'privilegies on dbsrv.* to 'root' @ '%'' at line 1.请问这个命令语句需要什么样的格式?用户root两边的单引号究竟是使用esc键下边的那个符号键还是使用键盘中纯粹的单引号键?%后边需要加identified by 这样的附加信息吗?请有过这方面经验的高手给予解答。谢谢。

解决方案 »

  1.   

    示例:
    grant all privileges on *.* to aa@'192.167.0.6' identified by "123";
      

  2.   

    自己测试一下不就OK了?
    GRANT ALL PRIVILEGES ON dbsrv.* TO root@'%' 
      

  3.   

    1. mysql> grant 权限1,权限2,…权限n on 数据库名称.表名称 to 用户名@用户地址 identified by ‘连接口令’;权限1,权限2,…权限n代表select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14个权限。
    当权限1,权限2,…权限n被all privileges或者all代替,表示赋予用户全部权限。
    当数据库名称.表名称被*.*代替,表示赋予用户操作服务器上所有数据库所有表的权限。
    用户地址可以是localhost,也可以是ip地址、机器名字、域名。也可以用’%'表示从任何地址连接。
    ‘连接口令’不能为空,否则创建失败。2. 键盘中纯粹的单引号键3.需要
      

  4.   

    grant all privieleges on dbsrv.* to 'root' @ '%'
             PRIVILEGES                root or `root`GRANT ALL PRIVILEGES ON dbsrv.* TO root@'%'
      

  5.   

    不行啊,还是这个结果:
    mysql> grant all privileges on dbsrv.* to 'root' @ '%';
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use near ''%''
    at line 1附加信息:root 在我本机上已经可以使用localhost地址,命令中root是否要用单引号括起来?
      

  6.   

    仔细看看别人的回复哦
    grant all privileges on dbsrv.* to root@'%';
      

  7.   


    看过了,这次我把数据库名部分改成了“*.*”, 结果是这样的:mysql> grant all privileges on *.* to root @ '%' identified by '123';
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use near ''%' i
    dentified by '123'' at line 1
      

  8.   

    找到错误原因了:root跟@及后边的ip地址之间不能有空格。