LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-20-2014, 09:19 PM   #1
romagnolo
Member
 
Registered: Jul 2009
Location: Montaletto
Distribution: Debian GNU/Linux
Posts: 107

Rep: Reputation: 5
MySQL Remote access forbidden only to a specific client


Hi,

I'm hit by a weird problem which is preventing a single specific instance of mysql-client to connect to a remote mysql-server. Connecting a client from other hosts to the same server works.

Details of setup:
A MySQL server is located at central.hwcharts.com; it is the master of a basic master-slave replication which replicates toward host0.hwcharts.com, located on a different physical machine which virtualizes (OpenVZ) the VM where the slave runs in.

The replication itself works flawlessly, but the problem is that a mysql-client launched from the "slave" machine cannot connect to the master:

Code:
mysql -h central.hwcharts.com -u hwcharts -pvery-long-pass hwcharts
ERROR 2003 (HY000): Can't connect to MySQL server on 'central.hwcharts.com' (111)
The same exact command executed from two other generic machines works OK and successfully connects to the master DB. Details on picture:

Code:
                               +---------------------------------------------------------------------+
    +--------------------+     |                          host0.hwcharts.com                         |
    |central.hwcharts.com|     |---------------------------------------------------------------------|
    |--------------------|     |                                                                     |
    |                    |     |   +-----+        +--------+        +-------------+                  |
    |    MySQL master    |-------->| NAT |---+--->| OpenVZ |---+--->| MySQL slave |                  |
    |                    |     |   +-----+   |    +--------+   |    +-------------+                  |
    +--------------------+     |             |                 |    +------------------------------+ |
                               |             |                 |    |      another generic VM      | |
                               |             |                 +--->| MySLQ-client works from here | |
                               |             |                      +----------------------------- + |
                               |             |                                                       |
                               |             |    +------------------------------+                   |
                               |             |    |  generic physical computer   |                   |
                               |             +--->| MySLQ-client works from here |                   |
                               |                  +------------------------------+                   |
                               |                                                                     |
                               +---------------------------------------------------------------------+
central.hwcharts.com is a rented VPS on its own; host0.hwcharts.com instead maps the IP to my home modem.

MySQL version is 5.5.31 on every machine, for both client and server software.
Operating systems are:
  • central.hwcharts.com: Debian 6.0.4
  • host0.hwcharts.com (every OpenVZ VM): Debian 7.1
  • host0.hwcharts.com (generic computer): Debian 6.0.3
 
Old 01-21-2014, 08:11 AM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
can they
Code:
telnet mysql-serverIP 3306
?
 
Old 01-21-2014, 08:37 AM   #3
romagnolo
Member
 
Registered: Jul 2009
Location: Montaletto
Distribution: Debian GNU/Linux
Posts: 107

Original Poster
Rep: Reputation: 5
From any host, including the "slave" host, I get:

Code:
$ telnet central.hwcharts.com 3306
Trying 75.127.3.156...
Connected to central.hwcharts.com.
Escape character is '^]'.
Y
5.5.31-1~dotdeb.0-logBq3IUNf�*b2o\^DxSrd!mysql_native_password
 
Old 01-21-2014, 08:50 AM   #4
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
Wild guess: MySQL-slave-server does not have proper nameserver configured. The master-slave replication is done with ip-adress not hostname.
---
Edit: Sorry didn't see your reply, obviously hostname lookup works fine.

Last edited by pingu; 01-21-2014 at 08:51 AM. Reason: Oops...
 
Old 01-21-2014, 09:12 AM   #5
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
I'd blame it on the access rules of mysql.users. Or maybe some fancy nat rules for this particular machine.
 
Old 01-21-2014, 09:40 AM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
mysql -h central.hwcharts.com -uroot -p -e "use mysql; select User, Host from user;"
output please.
 
Old 01-21-2014, 09:43 AM   #7
romagnolo
Member
 
Registered: Jul 2009
Location: Montaletto
Distribution: Debian GNU/Linux
Posts: 107

Original Poster
Rep: Reputation: 5
Post

I believe my setup is quite plain basic w/o much fancy customizations:
Code:
select user,host,password from mysql.user;
+------------------+-----------+-------------------------------------------+
| user             | host      | password                                  |
+------------------+-----------+-------------------------------------------+
| root             | localhost | *non-null-hash-replaced-xxxxxxxxxxxxxxxxx |
| debian-sys-maint | localhost | *non-null-hash-replaced-xxxxxxxxxxxxxxxxx |
| greatturn        | localhost |                                           |
| replication      | %         | *non-null-hash-replaced-xxxxxxxxxxxxxxxxx |
| hwcharts         | %         | *non-null-hash-replaced-xxxxxxxxxxxxxxxxx |
+------------------+-----------+-------------------------------------------+
For the NAT itself, it's a basic home DSL router. The NAT table is:

Code:
Rule	Application	Prot	Port_a	port_b 	Local IP address    comment
1 	EchoLink 	ALL 	5198 	5199 	192.168.1.23        unrelated physical computer
2 	- 	        - 	0 	0 	0.0.0.0
3 	-               -       0       0       0.0.0.0
4 	-               -       0       0       0.0.0.0
5 	- 	        - 	0 	0 	0.0.0.0
6 	GTservers 	ALL 	5100 	5149 	192.168.1.102       unrelated VM
7 	civservers 	ALL 	5000 	5099 	192.168.1.101       unrelated VM
8 	FTP     	ALL 	21 	21 	192.168.1.101       unrelated VM
9 	SSH 	        ALL 	22 	22 	192.168.1.10        OpenVZ physical host
10 	web 	        ALL 	80 	80 	192.168.1.200       unrelated VM
11 	mySQL 	        ALL 	3306 	3306 	192.168.1.102       unrelated VM
12 	sync akn 	TCP 	5150 	5150 	192.168.1.102       unrelated VM
The MySQL slave runs from VM 110 (IP 192.168.1.110), which as no NAT rules set up.
 
Old 01-21-2014, 09:48 AM   #8
romagnolo
Member
 
Registered: Jul 2009
Location: Montaletto
Distribution: Debian GNU/Linux
Posts: 107

Original Poster
Rep: Reputation: 5
Output of access attempts:

Executed from the slave host
Code:
$ mysql -h central.hwcharts.com -uroot -p -e "use mysql; select User, Host from user;"
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on 'central.hwcharts.com' (111)
Executed from one of the "generic" VM, from inside the same OpenVZ host:
Code:
$ mysql -h central.hwcharts.com -uroot -p -e "use mysql; select User, Host from user;"
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'87.19.245.199' (using password: YES)
Of course root access is explicitly forbidden.

Last edited by romagnolo; 01-21-2014 at 09:50 AM.
 
Old 01-21-2014, 10:03 AM   #9
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
Are you sure replication works?
It is not enough checking SHOW SLAVE STATUS, to be absolutely sure you have to check the records in slave's db.
Can you connect to slaves db with mysql client on itself?
 
Old 01-21-2014, 10:41 AM   #10
romagnolo
Member
 
Registered: Jul 2009
Location: Montaletto
Distribution: Debian GNU/Linux
Posts: 107

Original Poster
Rep: Reputation: 5
@pingu
I've checked right now, replication works: any change to master's tables (hwcharts.*) is immediately propagated to the slave database, flawlessly.

MySQL client-server connection also works fine between the following combination of hosts, except between host0.hwcharts.com and central.hwcharts.com:

Code:
From client                           To server              Works?    Comment

host0.hwcharts.com ("slave" VM host)  central.hwcharts.com   No
host0.hwcharts.com (any other host)   central.hwcharts.com   Yes
host0.hwcharts.com                    host0.hwcharts.com     Yes       localhost connection
central.hwcharts.com                  central.hwcharts.com   Yes       localhost connection
 
Old 01-21-2014, 10:59 AM   #11
ubungu
LQ Newbie
 
Registered: Jun 2012
Location: /home/ubungu
Posts: 27

Rep: Reputation: Disabled
Get your client's IP = xxx

and try to query: show grants for hwcharts@xxx

and can you paste query's output?
 
Old 01-21-2014, 11:11 AM   #12
romagnolo
Member
 
Registered: Jul 2009
Location: Montaletto
Distribution: Debian GNU/Linux
Posts: 107

Original Poster
Rep: Reputation: 5
The grants for user 'hwcharts'@'%' (the only hwcharts user) in master DB are:
Code:
show grants;
+---------------------------------------------------------------------------------------------------------+
| Grants for hwcharts@%                                                                                   |
+---------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'hwcharts'@'%' IDENTIFIED BY PASSWORD '*non-null-hash-replaced-xxxxxxxxxxxxxxxxx' |
| GRANT ALL PRIVILEGES ON `hwcharts`.* TO 'hwcharts'@'%'                                                  |
+---------------------------------------------------------------------------------------------------------+
User hwcharts is not defined for any other host, as shown is post #7.

Last edited by romagnolo; 01-21-2014 at 11:13 AM.
 
Old 01-21-2014, 11:20 AM   #13
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
It is of course good to check the permissioms on the mysql server.
But the message you get - "Can't connect to MySQL server" - makes me believe that you don't reach the server at all.
I think you need to find out where the connection is stopped. You have 4 systems to check, taken from your diagram:
MySQL slave
OpenVZ
NAT (home DSL router)
MySQL master

I suggest you run tcpdump on all these while trying to connect, it will at least show how far the request goes. Maybe you can't on the NAT device but if so just leave it out for now.
Also please post firewall rules for all systems. ("iptables -L")

And a small note: you have posted valid url's & ip-adress in this thread, maybe not a good idea! There are always bad robots out there sniffing for places to hack.
Easy fix is to write posts in whatever text-editor you have and do a search-replace. Then post with fake ip & url, and edit your earlier posts too.
 
1 members found this post helpful.
Old 01-21-2014, 11:29 AM   #14
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
A very wild shot in the dark, should not be possible but I've seen a few really weird home "routers" before...
Could it be that you can have only one connection at a time from a client?
Check it by opening two connections to mysql server from one client. You could also stop the slave and then try to connect via terminal.
Well, as I said not very likely - but then it is a weird problem!
 
1 members found this post helpful.
Old 01-21-2014, 12:43 PM   #15
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
Come to think of it, when did you start the replication, what have you done after that?
If you started replication and then later changed firewall rules the existing connection could still be kept alive but no new connections can be made. This applies on the client side too, it doesn't have to be the central-server that blocks.
So think of it, what has been done on the servers in the communication chain after replication was set up?
 
  


Reply

Tags
debian, mysql5, openvz, replication



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
access remote mysql db with mysql-administrator command uppalagayatri Linux - Newbie 4 05-13-2011 02:22 AM
[SOLVED] mysql remote access unkie888 Linux - Software 1 02-12-2011 12:55 AM
MySQL odbc connection remote client keirvt Linux - Server 4 07-29-2010 11:28 PM
[nfs] remote client do not have write access davidshen84 Linux - Software 2 02-23-2009 09:28 AM
NFS client : username specific access srilinux Linux - Server 1 11-18-2007 11:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration