LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-05-2006, 03:07 AM   #1
gain
LQ Newbie
 
Registered: Jul 2006
Distribution: Mandriva
Posts: 16

Rep: Reputation: 0
Can't connect remotely to MySQL...


Hi!

Why can't I connect to MySQL from a remote computer?

I am using MySQL Control center to connect to the remote computer.

The remote computer is running Mandrake 10.2 with 2 ethernet card but i disabled eth0 and activated eth1.

It has no firewall. I even tried stopping the iptables service but still I can't connect.

I have performed the necessary grants to the 'root' user account with the host set to '%'. In Mandrake 10.1 I don't encounter this problem.

Can anyone help.

Thanks.

Last edited by gain; 07-05-2006 at 03:23 AM.
 
Old 07-05-2006, 03:24 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You might try looking for the answer in the mysql manual at
/usr/share/doc/packages/mysql/manual.pdf

Also, look in the server logs. It may indicate what the problem is.
sudo less /var/lib/mysql/mysqld.log
or
sudo bzcat /var/lib/mysql/mysql.log.1.bz2 | less
to read the log backup.
 
Old 07-05-2006, 03:28 AM   #3
jayakrishnan
Member
 
Registered: Feb 2002
Location: India
Distribution: Slacky 12.1, XP
Posts: 992

Rep: Reputation: 30
What error message are u getting?
 
Old 07-05-2006, 04:11 AM   #4
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Is the mysqld daemon running on the Mandrake box? And is it configured to listen to eth1 (ie not localhost)?
 
Old 07-05-2006, 08:55 PM   #5
gain
LQ Newbie
 
Registered: Jul 2006
Distribution: Mandriva
Posts: 16

Original Poster
Rep: Reputation: 0
To jschiwal, yes I looked at the log files, in Mandrake its located at /var/log/mysqld/mysqld.log but I find no error entries there. I'm still looking for the mysql manual.

To jayakrishnan, the error I get is ERROR 2003: Can't connect to MySQL server on 'XXX.xxx.XXX.xxx' (10061)

To timmeke, yes the Mandrake daemon is running. I can connect to it locally. When i checked the my.cnf file there is no bind-address setting in it. Additionally when I peform a netstat -tap command I do not see mysql in list of daemons listening or active. What should I do?

Thanks for all the replies

Last edited by gain; 07-05-2006 at 09:54 PM.
 
Old 07-05-2006, 10:42 PM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Check which port number is listed in the mysqld.log on the server:

060705 21:34:23 mysqld started
060705 21:34:24 InnoDB: Started; log sequence number 0 43655
060705 21:34:24 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.0.18' socket: '/var/lib/mysql/mysql.sock' port: 3306 SUSE MySQL RPM

I noticed that mine is different. It is possible to have more than one instance of mysqld and have them listen on different ports, as this config example from the manual indicates:
Code:
# This file should probably be in your home dir (~/.my.cnf)
# or /etc/my.cnf
# Version 2.1 by Jani Tolonen
[mysqld_multi]
mysqld = /usr/local/bin/mysqld_safe
mysqladmin = /usr/local/bin/mysqladmin
user = multi_admin
password = multipass
[mysqld2]
socket = /tmp/mysql.sock2
port = 3307
pid-file = /usr/local/mysql/var2/hostname.pid2
datadir = /usr/local/mysql/var2
language = /usr/local/share/mysql/english
user = john
[mysqld3]
socket = /tmp/mysql.sock3
port = 3308
pid-file = /usr/local/mysql/var3/hostname.pid3
datadir = /usr/local/mysql/var3
language = /usr/local/share/mysql/swedish
user = monty
From your remote host, enter "telnet <serverhost> <mysqlport>"

If your host has access, and you have the port number right, then you should get some garbage back.

Does your remote host have priviledges to access the database?

Are both your remote host and the mysql server on a LAN, or are you connecting over the internet? If it's the latter, you should be using a firewall and accessing the database over a secure VPN or an SSH tunnel.

I looked in rpm.pbone.net. It looks look your documentation is in
/usr/share/doc/MySQL50-common-5.0.2/manual-split/manual_Introduction.html
There is a Post Script version
/usr/share/doc/MySQL50-common-5.0.2/manual.ps

Read through the /etc/my.cnf file. Here is a segment:
Code:
# The MySQL server
[mysqld]
port            = 3306
socket          = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
Note the port value in this global configuration file and whether skip-networking is commented out or not.

Last edited by jschiwal; 07-05-2006 at 10:50 PM.
 
Old 07-05-2006, 11:37 PM   #7
gain
LQ Newbie
 
Registered: Jul 2006
Distribution: Mandriva
Posts: 16

Original Poster
Rep: Reputation: 0
Thanks. I'm getting somewhere I think. I looked at the log file and this is what I see:

Quote:
060706 12:34:47 mysqld started
060706 12:34:47 InnoDB: Started; log sequence number 0 43654
/usr/sbin/mysqld: ready for connections.
Version: '4.1.11' socket: '/var/lib/mysql/mysql.sock' port: 0 Source distribution
Note that port 0 is used. So in the my.cnf I added the entry port = 3306. I restarted the mysqld and yet when I checked the log file it is still using port 0. Could it be possible that mysqld is messed up?

telnet localhost 3306 isn't working as well as telnet <remotehost> 3306 either.

The server and the clients are on a local area network.

Here is the content of the my.cnf file:

Quote:
[mysqld]
datadir=/var/lib/mysql
port = 3306
socket=/var/lib/mysql/mysql.sock

# Default to using old password format for compatibility with old and
# shorter password hash.
# Reference: http://dev.mysql.com/doc/mysql/en/Password_hashing.html
old_passwords=1

[mysql.server]
user=mysql
basedir=/var/lib

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

Last edited by gain; 07-06-2006 at 01:06 AM.
 
Old 07-06-2006, 03:21 AM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Did you restart mysql after changing /etc/my.cfg?
Also, did you find the manual. The post installation section is very important.
Right after installing, there are a couple database tables that don't have passwords.
The manual even details how to access the database through ssh, and how to work with
certificates. If the server is visible from the internet, this will be very important.
 
Old 07-11-2006, 11:43 PM   #9
gain
LQ Newbie
 
Registered: Jul 2006
Distribution: Mandriva
Posts: 16

Original Poster
Rep: Reputation: 0
Nope can't figure it out yet. Oh my. If I do a netstat -ln | grep mysql here is what I get:

Quote:
# netstat -ln | grep mysql
unix 2 [ ACC ] STREAM LISTENING 10776 /var/lib/mysql/mysql.sock
Which means that MySQLd is listening alright. The documentation isn't helpful but I've found an online documentation from the MySQL website that look's like quite a read. I'll see what I can find in there. Hmm...
 
Old 07-14-2006, 11:22 PM   #10
ShatteredArm
LQ Newbie
 
Registered: Aug 2005
Location: AZ
Distribution: FC4, Gentoo
Posts: 22

Rep: Reputation: 15
I'm having basically the same problem.
"ERROR 2003 (HY000): Can't connect to MySQL server on 192.168.xxx.xxx"

If I figure anything out, I'll let you know.
 
Old 07-14-2006, 11:26 PM   #11
ShatteredArm
LQ Newbie
 
Registered: Aug 2005
Location: AZ
Distribution: FC4, Gentoo
Posts: 22

Rep: Reputation: 15
Well that was quick, I got mine working.. lol

In my.cnf, there's a value called bind-address (mine's right below the skip-networking line). By default it was set to 127.0.0.1. When I changed it to 192.168.xxx.xxx, it worked.

Does anybody know if there's a better way to do this? I don't want to go running around changing config files if I change the computer's network IP.
 
Old 07-17-2006, 09:51 PM   #12
gain
LQ Newbie
 
Registered: Jul 2006
Distribution: Mandriva
Posts: 16

Original Poster
Rep: Reputation: 0
Yeah I'm familiar with those things. Have been there. I tried those. And I can't still make remote connections.

Quote:
Does anybody know if there's a better way to do this? I don't want to go running around changing config files if I change the computer's network IP.
There is a better way. Just remove the bind-address (or comment it out). You don't have to set it to any remote address. That way any remote host can connect to your server not just the IP you set, unless that's what you want. Besides, I'm not sure though, if you set the bind-address to a remote computer, that may affect connection locally. Good for you though. You solved your problem.

Obviously my problem goes beyond changing the my.cnf file. Because as I said I've done that. I removed bind-address, I removed skip-networking but remote comp can't still connect. Yeah, I restarted mysqld after changing the settings.

Last edited by gain; 07-17-2006 at 09:54 PM.
 
Old 08-07-2006, 09:32 PM   #13
gain
LQ Newbie
 
Registered: Jul 2006
Distribution: Mandriva
Posts: 16

Original Poster
Rep: Reputation: 0
Update: I've discovered that the default used by mysql in mandriva uses the --skip-networking option regardless of the settings in the my.cnf file. That is the reason why I can't connect to the server from other machines.

I discovered this when I issue this command:

ps -efH | grep mysql

The output I get is:
Quote:
root 17605 1 0 09:07 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=/etc/my.cnf --skip-networking --pid-file=/var/run/mysqld/mysqld.pid

mysql 17644 17605 1 09:07 pts/0 00:00:23 /usr/sbin/mysqld --defaults-file=/etc/my.cnf --basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --port=3306 --socket=/var/lib/mysql/mysql.sock --skip-networking
I can't figure out how to change this default. Can anyone help?

Last edited by gain; 08-07-2006 at 09:33 PM.
 
Old 08-07-2006, 10:10 PM   #14
ShatteredArm
LQ Newbie
 
Registered: Aug 2005
Location: AZ
Distribution: FC4, Gentoo
Posts: 22

Rep: Reputation: 15
I don't know, maybe --skip-networking=FALSE? Possibly it was originally configured with --skip-networking and you have to recompile.
 
Old 08-10-2006, 12:45 AM   #15
gain
LQ Newbie
 
Registered: Jul 2006
Distribution: Mandriva
Posts: 16

Original Poster
Rep: Reputation: 0
Okay. I finally solved it. After going through the system, I discovered an undocumented(?) configuration setting found at /etc/sysconfig/mysqld file. And sure enough there it was:

Quote:
# (oe) Remove --skip-networking to enable network access from
# non local clients. Access from localhost will still work.
MYSQLD_OPTIONS="--skip-networking"

# (oe) set TMPDIR and TMP environment variables
TMPDIR="${datadir}/.tmp"
TMP="${TMPDIR}"
When I removed the --skip-networking option and restarted mysqld, I finally made a successful connection from a remote machine to the server.

I hope that this will be of help to someone who had the same problem as I did.

Last edited by gain; 08-10-2006 at 12:46 AM.
 
  


Reply

Tags
mysql



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
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. NoviceW Linux - Networking 17 09-17-2014 02:13 PM
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. suziecorbett Linux - Software 8 10-09-2008 01:52 AM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 08:44 AM
connect remotely pyre Linux - Newbie 8 03-19-2004 11:20 AM
Can't connect to MySQL server remotely on RedHat 9 bper Red Hat 4 10-02-2003 10:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:54 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