首页 > 代码库 > MySQL创建用户与授权(CentOS6.5)
MySQL创建用户与授权(CentOS6.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 ACCEPTCOMMIT# 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
MySQL创建用户与授权(CentOS6.5)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。