php - 如何修改mysql端口并对外开放。。
某草草
某草草 2017-05-16 13:04:41
0
2
692

如何修改mysql端口并对外开放。。有什么尤为简单的方法 目前使用的是3306端口 不让外网访问的

某草草
某草草

reply all(2)
Ty80

The following is for the redhat/centos system, please make adjustments accordingly for other systems:
1. If you are sure that the process can be opened correctly, go to step 2. If not, please make sure that the program can be opened correctly
2. Modify the listening port:

    修改MySQL配置文件/etc/my.cnf,在[mysqld]找到如下配置:
    bind-address = 127.0.0.1
    注释掉该行或改成0.0.0.0,然后重启mysql。

3. Authorize remote users:

    # %表示所有客户端IP
    mysql> grant all on *.* to user_name@"%" identified by "user_password"; 

    # 刷新权限:
    FLUSH PRIVILEGES;

4. Firewall open port:

    打开防火墙配置:
    vim  /etc/sysconfig/iptables
    
    增加一行:
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
    
    重启防火墙:
    service  iptables restart
phpcn_u1582

I took a look just now. My.ini is the configuration file of mysql. If you change the port, it should be fine.


[client]
port=3306
[mysql]
default-character-set=gbk

[mysqld]
port=3306
basedir="C:/Program Files/phpStudy/MySQL/"
datadir="C:/Program Files/phpStudy/MySQL/data/"
character-set-server=gbk
default-storage-engine=MyISAM
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
max_connections=512

query_cache_size=0
table_cache=256
tmp_table_size=18M

thread_cache_size=8
myisam_max_sort_file_size=64G
myisam_sort_buffer_size=35M
key_buffer_size=25M
read_buffer_size=64K
read_rnd_buffer_size=256K
sort_buffer_size=256K

innodb_additional_mem_pool_size=2M

innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=1M

innodb_buffer_pool_size=47M
innodb_log_file_size=24M
innodb_thread_concurrency=8
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!