MySQL Remote Access Problem

General support questions
Post Reply
User avatar
MacArthur
Posts: 3
Joined: 2018/03/29 18:32:26

MySQL Remote Access Problem

Post by MacArthur » 2018/03/29 18:58:07

Hi, newbie here, just start learning Linux. Got this old PC, installed CentOS 6.9 (too old for CentOS 7) and MariaDB 10.2.14 using instructions here (https://www.if-not-true-then-false.com/ ... ntos-rhel/). I've added the INPUT rule into IPTABLES as instructed, were able to login to the MariaDB, create database/user, everything is fine

However, when I tried to access this MariaDB (192.168.1.11) from another Windows 7 PC (192.168.1.4), it just won't connect. They can ping each other, but telnet will fail

Code: Select all

C:\windows\system32>telnet 192.168.1.11 3306
Connecting To 192.168.1.11...Could not open connection to the host, on port 3306: Connect failed
I installed WorkBench on Windows 7 PC but got this error when trying to connect
Image

Any help/suggestion/advice is appreciated!
Last edited by MacArthur on 2018/04/02 16:09:46, edited 1 time in total.

Whoever
Posts: 1357
Joined: 2013/09/06 03:12:10

Re: MySQL Remote Access Problem

Post by Whoever » 2018/03/30 02:32:06

I think that the default installation of MySQL disables remote access to the database. I would assume that MariaDB is the same.

Look in the file /etc/my.cnf. You will probably find the following:

Code: Select all

[mysqld]
...
skip-networking
If so, remove the "skip-networking" and restart MariaDB.

User avatar
MacArthur
Posts: 3
Joined: 2018/03/29 18:32:26

Re: MySQL Remote Access Problem

Post by MacArthur » 2018/04/02 16:07:25

Thanks. But it's not there. Don't see anything inside the .cnf

Code: Select all

[root@EUP01 etc]# pwd
/etc
[root@EUP01 etc]# more my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

[root@EUP01 etc]# 
[root@EUP01 etc]# cd my.cnf.d/
[root@EUP01 my.cnf.d]# ls -ltr
total 12
-rw-r--r--. 1 root root  232 Mar 26 12:41 mysql-clients.cnf
-rw-r--r--. 1 root root  763 Mar 26 12:41 enable_encryption.preset
-rw-r--r--. 1 root root 1091 Mar 29 12:35 server.cnf
[root@EUP01 my.cnf.d]# grep 'skip-networking' *.cnf
[root@EUP01 my.cnf.d]# 

Any other ideas?

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: MySQL Remote Access Problem

Post by TrevorH » 2018/04/02 16:19:36

I've added the INPUT rule into IPTABLES as instructed, were able to login to the MariaDB, create database/user, everything is fine
Are you using iptables.service or firewalld? If you use firewalld then do not use iptables to manipulate rules behind its back as it doesn't like it and removes/reverts any rule changes you make. Use firewall-cmd to manipulate firewalld rules. If using iptables.service then did you insert a new rule or append a new one to the end of the chain? If you appended then it's probably gone after the global REJECT line that disallows all not-explicitly-allowed connections.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
MacArthur
Posts: 3
Joined: 2018/03/29 18:32:26

Re: MySQL Remote Access Problem

Post by MacArthur » 2018/04/02 16:42:12

I'm using iptables. This is what I have:

Code: Select all

                                             
[root@EUP01 my.cnf.d]# nano -w /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-I INPUT -p tcp --dport 80 -j ACCEPT
COMMIT

[root@EUP01 my.cnf.d]# 
[root@EUP01 my.cnf.d]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
[root@EUP01 my.cnf.d]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http 
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh 
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:mysql 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
[root@EUP01 my.cnf.d]# 
Don't know what I've been messing around, not sure how that "Chain FORWARD"/"Chain OUTPUT" thing get in there... :(

Post Reply