http://blog.csdn.net/leili0806/article/details/8573636,谢谢这位仁兄

1.创建新用户的SQL语句:

     CREATE USER 'pig'@'192.168.1.101_' IDENDIFIED BY '123456';

    // pig 是用户名,@后面的是指定ip(如果不限制只能在某个ip,@后面改为‘%’),by后面的是 密码

2.设置这个用户的权限,使用GRANT语句

   (如限制某个用户只能查询,不能修改,或者限定只能查询特定的表

      语法:

     mysql> grant 权限1,权限2,...权限n on 数据库名称.表名称 to 用户名@用户地址 identified by '连接口令';

 

     可选的权限列表:select, insert, update, delete, create, drop,

                      index, alter, grant, references, reload,

                     shutdown, process, file等14个权限

 

    eg:

      1.  mysql> grant select,insert,update,delete,create,drop on vtdc.employee to joe@10.163.225.87 identified by '123';

        给来自10.163.225.87的用户joe分配可对数据库vtdc的employee表

       进行select,insert,update,delete,create,drop等操作的权限,并设定口令为123。

 

     2. mysql>grant all privileges on vtdc.* to joe@10.163.225.87 identified by '123';

       给来自10.163.225.87的用户joe分配可对数据库vtdc所有表进行所有操作的权限,并设定口令为123。

 

     3. mysql>grant all privileges on *.* to joe@10.163.225.87 identified by '123';

         给来自10.163.225.87的用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。

 

     4. mysql>grant all privileges on *.* to joe@localhost identified by '123';

         给本机用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。

     5. mysql>flush privileges;   //刷新系统权限表

相关文章:

  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
猜你喜欢
  • 2021-11-23
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
  • 2021-11-11
  • 2021-09-07
  • 2021-12-20
相关资源
相似解决方案