简体   繁体   English

启用mySQL远程连接端口3306 Plesk 11.5 CENTOS

[英]Enable mySQL remote connections port 3306 Plesk 11.5 CENTOS

I am having problems connecting to our mysql server remotely. 我在远程连接到我们的mysql服务器时遇到问题。 We have 2 servers both running Plesk 11.5 one of them is linux (IP 99.99.99.99) and the other is Windows R2 2008 (IP 88.88.88.88). 我们有2台服务器都运行Plesk 11.5,其中一台是linux(IP 99.99.99.99),另一台是Windows R2 2008(IP 88.88.88.88)。

Note: These are not the true IP addresses but for security I have replaced them with those above. 注意:这些不是真正的IP地址,但是出于安全考虑,我已将它们替换为上述IP地址。

I am trying to connect to the mysql server on the linux machine from the windows machine. 我正在尝试从Windows计算机连接到Linux计算机上的mysql服务器。 I am connecting via PHP scripts using mysqli 我正在使用mysqli通过PHP脚本进行连接

Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2003): Can't connect to MySQL server on '99.99.99.99' (10060) in C:\Inetpub\vhosts\oldburywells.co.uk\httpdocs\setup\includes\db.php on line 12
Failed to connect to MySQL: (2003) Can't connect to MySQL server on '99.99.99.99' (10060)

The contents of /etc/my.cnf is below: /etc/my.cnf的内容如下:

[mysqld]
set-variable=local-infile=0
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
# Forced OLD_PASSWORD format is turned OFF by Plesk
#old_passwords=1
port=3306
bind-address=99.99.99.99
# skip-networking

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

In the mysql database - db table the record for the host is this ignore the insert statement, this was the easiest way for me to display the options: 在mysql数据库-db表中,主机的记录是此忽略insert语句,这是我显示选项的最简单方法:

INSERT INTO `db` (`Host`, `Db`, `User`, `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Grant_priv`, `References_priv`, `Index_priv`, `Alter_priv`, `Create_tmp_table_priv`, `Lock_tables_priv`, `Create_view_priv`, `Show_view_priv`, `Create_routine_priv`, `Alter_routine_priv`, `Execute_priv`) VALUES
('%', 'designjazzsetup', 'designjazzsu', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y');

The user record in the user table looks like this: 用户表中的用户记录如下所示:

INSERT INTO `user` (`Host`, `User`, `Password`, `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`, `ssl_type`, `ssl_cipher`, `x509_issuer`, `x509_subject`, `max_questions`, `max_updates`, `max_connections`, `max_user_connections`) VALUES
('%', 'designjazzsu', '*812A9EC8DA3040D2FBE1FDE5A71B25011F43A358', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', '', '', '', '', 0, 0, 0, 0);

The contents of /etc/sysconfig/iptables: / etc / sysconfig / iptables的内容:

# Generated by iptables-save v1.3.5 on Tue Mar 25 10:57:08 2014
*filter
:INPUT ACCEPT [789031949:87191570991]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [261535305:1869618743997]
#-A INPUT -s 88.88.88.88 -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
COMMIT
# Completed on Tue Mar 25 10:57:08 2014

When I try to telnet to the linux server with mysql on (99.99.99.99) on port 3306 it times out, this happens on the windows server (88.88.88.88) and also from my local office PC. 当我尝试通过端口3306(99.99.99.99)上的mysql远程登录到linux服务器时,它超时,这在Windows服务器(88.88.88.88)上以及从我的本地办公室PC上都发生了。

On the windows server the contents of my db.php include (this is the server that is trying to connect to the linux mysql) looks like this: 在Windows服务器上,我的db.php include的内容(这是试图连接到Linux mysql的服务器)看起来像这样:

<?php
session_start();
$host = "99.99.99.99";
$user = "designjazzsu";
$password = "52dJ5rH6kL77hgd!";
$db = "designjazzsetup";

$mysqli = new mysqli($host, $user, $password, $db);
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
#echo $mysqli->host_info . "\n";

$mysqli = new mysqli("99.99.99.99", $user, $password, $db, 3306);
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

#echo $mysqli->host_info . "\n";
?>

I have spent over a day on this and am completely stuck. 我花了整整一天的时间,完全陷入困境。

I have a database on the linux server that needs to be shared between both servers. 我在linux服务器上有一个数据库,需要在两个服务器之间共享。

Any help would be greatly appreciated guys. 任何帮助将不胜感激的家伙。

And thanks. 谢谢你

Kind regards, Michael 亲切的问候,迈克尔

You can't bind on two addresses. 您不能在两个地址上绑定。 You can bind on 0.0.0.0 address and make rules in firewall. 您可以绑定0.0.0.0地址并在防火墙中制定规则。 Example and useful links: 示例和有用的链接:

unix-linux-mysqld-server-bind-to-more-than-one-ip-address unix-linux-mysqld-server-bind绑定到多个IP地址

mysql-bind-to-more-than-one-ip-address MySQL绑定到一个以上的IP地址

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM