Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Remote MySQL Connection
PostPosted: Sat Nov 21, 2009 1:51 pm 
Offline
Newbie

Joined: Sat Nov 21, 2009 1:46 pm
Posts: 4
I have a script here on my home computer that should connect to my MySQL server. I have port 3306 open and all the MySQL login info right. But whenever I try to run the script it says it cannot connect to the server. Why would that be happening.


Top
   
 Post subject:
PostPosted: Sat Nov 21, 2009 2:36 pm 
Offline
Senior Member

Joined: Sun Aug 02, 2009 1:32 pm
Posts: 222
Website: https://www.barkerjr.net
Location: Connecticut, USA
Do you have a firewall installed on the server? Check netstat to see if it's listening on the wildcard address.


Top
   
 Post subject:
PostPosted: Sat Nov 21, 2009 3:26 pm 
Offline
Newbie

Joined: Sat Nov 21, 2009 1:46 pm
Posts: 4
I'm not exactly sure how to tell if it is listening from this....
Code:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 localhost:mysql         *:*                     LISTEN
tcp        0      0 localhost:874           *:*                     LISTEN
tcp        0      0 *:sunrpc                *:*                     LISTEN
tcp        0      0 *:ssh                   *:*                     LISTEN
tcp        0      0 localhost:smtp          *:*                     LISTEN
tcp6       0      0 [::]:www                [::]:*                  LISTEN
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN
udp        0      0 *:bootpc                *:*
udp        0      0 *:sunrpc                *:*
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     STREAM     LISTENING     11272    /var/run/mysqld/mysqld.sock

I assumed that you wanted me to run "netstat -l"

And no, I don't have a firewall running.

Thanks!


Top
   
 Post subject:
PostPosted: Sat Nov 21, 2009 3:56 pm 
Offline
Junior Member

Joined: Sat Jul 11, 2009 7:19 am
Posts: 30
Location: Martinique
your mysql server only accepts local connection (as evidenced by your netstat output).


Top
   
 Post subject:
PostPosted: Sat Nov 21, 2009 4:03 pm 
Offline
Newbie

Joined: Sat Nov 21, 2009 1:46 pm
Posts: 4
How could I go about fixing that?


Top
   
 Post subject:
PostPosted: Sat Nov 21, 2009 4:35 pm 
Offline
Junior Member
User avatar

Joined: Sun Oct 02, 2005 11:54 am
Posts: 43
Website: http://www.garyscott.net
Location: Goleta, CA
In /etc/mysql/my.cnf will be a setting bind-address=127.0.0.1

Just put a # in front of this to comment it out and restart MySQL.

This setting is forcing it to listen only on localhost.

The my.cnf might be in a different location.

I'm not going to lecture much but running without a firewall or connecting to MySql remotely like this is a big security risk, but I am also paranoid.


Top
   
 Post subject:
PostPosted: Sat Nov 21, 2009 5:10 pm 
Offline
Newbie

Joined: Sat Nov 21, 2009 1:46 pm
Posts: 4
Well, the error message changed because of that. Now it says that I am not allowed to connect. But at least it is finding it.

And with the security thing, I would be more careful but I'm not doing anything that is important. This is just for fun for me. If this was my job or something, I would take security more seriously.

Thanks for your help so far.


Top
   
 Post subject:
PostPosted: Sat Nov 21, 2009 11:59 pm 
Offline
Junior Member
User avatar

Joined: Sun Oct 02, 2005 11:54 am
Posts: 43
Website: http://www.garyscott.net
Location: Goleta, CA
I think that there is setting if the user can connect from. In the mysql database there is a a table called users. Mine has User: root, Host: localhost.

I have never connected remotely so I do not know what to do, but that might be the next place to look.

Google for mysql remote root and try the first result.


Top
   
 Post subject:
PostPosted: Sun Nov 22, 2009 7:36 am 
Offline
Senior Member
User avatar

Joined: Sat Oct 16, 2004 11:13 am
Posts: 176
Yes, look at "Host" field of table "user", database "mysql". You can edit the privileges manually, or by using Webmin, phpMyAdmin, etc.


Top
   
 Post subject:
PostPosted: Sun Dec 06, 2009 11:21 pm 
Offline
Senior Member
User avatar

Joined: Sun Dec 06, 2009 9:02 pm
Posts: 54
Website: http://mark.watero.us/
Location: Las Vegas
Not to dredge up a mildly old topic and change its direction, but I've heard a lot of people who are paranoid about allowing MySQL to listen outside of the local loopback.

Before I started using VPS I've used a lot of major shared hosts where your mysql server was mysql.domain.com, and usually tied to another IP (since it sat on their dedicated mysql servers).

If you have it open to listen on outside connections, and you know there's only one, maybe even two other IPs that are going to be connecting to MySQL and you firewall off everything outside of those addresses, I don't see where the risk lies?

I mean the obvious is that if there's no potential to connect to it at all, it is definitely more secure. But if you properly set your firewall...


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group