MySQL数据库设置远程访问权限方法小结 简单,粗暴,有截图

当然,你必须进入mysql中 (原文地址:http://www.jb51.net/article/42441.htm)

 

若忘记密码  

以下个是无密码进入mysql 

 

./mysqld_safe --skip-grant-tables   

./mysqld --console --skip-grant-tables --shared-memory 

./mysqld --skip-grant-tables

./mysql  --skip-grant-tables

 

无密码进入mysql  

 

 

 

1,设置访问单个数据库权限

  mysql>grant all privileges on test.* to 'root'@'%';

  说明:设置用户名为root,密码为空,可访问数据库test

 

 

2.设置访问全部数据库权限

   mysql>grant all privileges on *.* to 'root'@'%';

    说明:设置用户名为root,密码为空,可访问所有数据库*

 

3.设置指定用户名访问权限

  mysql>grant all privileges on *.* to 'testyonghu'@'%';

 说明:设置指定用户名为 testyonghu,密码为空,可访问所有数据库*

 

4.设置密码访问权限

  mysql>grant all privileges on *.* to 'zhangsan'@'%' IDENTIFIED BY '123456';

说明:设置指定用户名为zhangsan,密码为123456,可访问所有数据库*

 

 

5.设置指定可访问主机权限

 grant all privileges on *.* to 'lisi'@'10.2.1.11';

 说明:设置指定用户名为lisi,可访问所有数据库*,只有10.2.1.11这台机器有权限访问

 

 

所有的设置完之后,还需要  执行 mysql>  FLUSH PRIVILEGES;

然后退出mysql生效

 

 

 若出现了 

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

执行

  flush privileges;

 

 

最后来张图吧,无图无真相

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值