我的apache正在8113
端口而不是80
上运行。
我想远程访问我的mysql数据库。我尝试了以下步骤。
Bind-address XXX.XX.XX.XXX in /etc/my.cnf
Create Database
and run the command
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'IP' IDENTIFIED BY 'PASSWORD';
但无法连接。我正在使用heidi sql进行连接。
答案 0 :(得分:13)
/etc/my.cnf中的绑定地址XXX.XX.XX.XXX
评论专栏:
或
service mysqld restart
登录mysql并点击此查询:
GRANT ALL PRIVILEGES ON dbname.* TO 'username'@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
quit;
添加防火墙规则:
iptables -I INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
答案 1 :(得分:11)
以下编辑my.cnf:
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/English
bind-address = xxx.xxx.xxx.xxx
# skip-networking
编辑后点击service mysqld restart
登录mysql并点击此查询:
GRANT ALL ON foo.* TO bar@'xxx.xxx.xxx.xxx' IDENTIFIED BY 'PASSWORD';
多数民众赞成它确保你的iptables允许从3306连接,如果没有提出以下内容:
iptables -A INPUT -i lo -p tcp --dport 3306 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 3306 -j ACCEPT
答案 2 :(得分:0)
如果允许IP给mysql服务器linux机器。您可以执行以下命令-
nano /etc/httpd/conf.d/phpMyAdmin.conf and add Desired IP.
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8
Order allow,deny
allow from all
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 192.168.9.1(Desired IP)
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
#Allow from All
Allow from 192.168.9.1(Desired IP)
</IfModule>
更新后,请使用以下命令重新启动-
sudo systemctl restart httpd.service