MySQL创建用户与授权(CentOS6.5)

2018-06-17 23:29:45来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

 

1.相关SQL语句

#创建用户与授权方法
##本地访问
create user 'zend'@'localhost' IDENTIFIED BY '123456';
grant ALL  privileges ON zenddb.* TO 'zend'@'localhost';
##本地访问
create user 'zend'@'127.0.0.1' IDENTIFIED BY '123456';
grant ALL privileges   ON zenddb.* TO 'zend'@'127.0.0.1';
##针对远程访问
create user 'zend'@'%' IDENTIFIED BY '123456';
grant ALL privileges   ON zenddb.* TO 'zend'@'%';

#刷新权限 
flush privileges;
#撤销用户权限 删除用户
REVOKE ALL ON  zenddb.* FROM 'zend'@'localhost';
DROP USER 'zend'@'localhost';

2.退出MySQL,重启服务
/etc/init.d/mysqld restart

3.问题处理
3.1 连接MySQL数据库时出现The dirver has not received any packets from the server
解决办法:查看iptables后发现是端口3306被防火墙阻止
[root@zendlinux support-files]# vi /etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Tue Nov  8 16:07:49 2016
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [1:184]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 3306 -j DROP
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
-A INPUT -m state --state NEW -m tcp -p tcp --dport 15672 -j ACCEPT
COMMIT
# Completed on Tue Nov  8 16:07:49 2016
-A INPUT -p tcp -m tcp --dport 3306 -j DROP 修改  -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
接下来,重启服务即可service iptables restart

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:java开发之阿里云对象存储OSS和云数据库Memcache的使用

下一篇:SQL查询语句分类