ctrlC & ctrlV

我们不生产代码,我们只是代码的搬运工~

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

1、更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"127.0.0.1"改成"%" ,如果没有对应的记录,则执行红字的sql先插入一条,如果有就不用执行了(我用的数据库是5.7版本,插入语句可能有些差别,如果不符合可自行改造)。

mysql>use mysql; 

mysql>insert into user(Host,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Reload_priv,Shutdown_priv,Process_priv,File_priv,Grant_priv,References_priv,Index_priv,Alter_priv,Show_db_priv,Super_priv,Create_tmp_table_priv,Lock_tables_priv,Execute_priv,Repl_slave_priv,Repl_client_priv,Create_view_priv,Show_view_priv,Create_routine_priv,Alter_routine_priv,Create_user_priv,Event_priv,Trigger_priv,Create_tablespace_priv,ssl_type,ssl_cipher,x509_issuer,x509_subject,max_questions,max_updates,max_connections,max_user_connections,plugin,authentication_string,password_expired,password_last_changed,password_lifetime,account_locked) select '127.0.0.1',User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Reload_priv,Shutdown_priv,Process_priv,File_priv,Grant_priv,References_priv,Index_priv,Alter_priv,Show_db_priv,Super_priv,Create_tmp_table_priv,Lock_tables_priv,Execute_priv,Repl_slave_priv,Repl_client_priv,Create_view_priv,Show_view_priv,Create_routine_priv,Alter_routine_priv,Create_user_priv,Event_priv,Trigger_priv,Create_tablespace_priv,ssl_type,ssl_cipher,x509_issuer,x509_subject,max_questions,max_updates,max_connections,max_user_connections,plugin,authentication_string,password_expired,password_last_changed,password_lifetime,account_locked from user where host='localhost' and User='root';

mysql>update user set host = '%' where user = 'root' and host='127.0.0.1';
mysql>select host, user from user;
mysql>FLUSH PRIVILEGES;

 

 

2、指定授权,允许使用root/root从任何主机连接到mysql服务器:

mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

mysql>FLUSH PRIVILEGES;

 

 3、配置防火墙开放3306端口(适用于Centos6,由于Centos7默认使用了firewall做防火墙,所以需要对firewall做配置,配置方法类似,可自行谷歌)

编译 vim /etc/sysconfig/iptables

 

增加 -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

 

4、重启防火墙 service iptables restart ,一定要用有root权限的账号

 

 

 

 

posted on 2018-01-29 16:37  Rocky_  阅读(232)  评论(0编辑  收藏  举报