Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I open port 3306 on my Ubuntu Linux Server....?

Posted on 2008-06-18
19
Medium Priority
?
7,716 Views
Last Modified: 2013-11-16
Experts:

I"m trying to access my MySQL database that is located on a remote Ubuntu Linux Server. I need to verify that Port 3306 is OPEN and LISTENING on this Linux Server.

I'm trying to access the Linux server using a Windows XP Pro workstation.

Please advise...thanks
M
0
Comment
Question by:MIKE
  • 8
  • 6
  • 5
19 Comments
 
LVL 4

Expert Comment

by:albuitra
ID: 21817346
try from win xp with this
telnet IP_UBUNTU 3306
if the system shows something a black screen, so myql port is open
in this case, you have to create a user in mysql, and authorize to connect from xp
but if the response is something like could not open connection to host indicates that the firewall is active
in this case, you have to deactivate the rule that filter mysql
0
 
LVL 7

Expert Comment

by:Zippit
ID: 21817387
you shouldn't have to open port 3306 explicitly unless you are running some kind of firewally.  more likely your MySQL server is not running, or is only listening on the local machine and not on the network.  Make sure the network section is uncommented in the mysql.conf file on your linux box (it is commented out by default).  The file should be here: (this is on Debian and MySql 5...so it may vary a little):

/etc/mysql/my.cnf

You'll also have to make sure the user you are trying to login as has rights to access to the db from the network.  Every user has a hostname associated with their name that determines where they are allowed to connect from.  Usually you want to keep it to 127.0.0.1, but some users will require network access, so it is usually set to the client IP they will be connecting from, or '%' to allow them to connect from any host.
0
 
LVL 17

Author Comment

by:MIKE
ID: 21817415
albuitra:

Ok..is said I could NOT open a connection to host: 3306, connection failed.

So, how do I DEACTIVATE the rule that filters MYSQL....???

Thanks
M
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Author Comment

by:MIKE
ID: 21817452
Zippet:

MySQL is indeed running, and it is "listening" on port 3306.

I'm not sure if it is listening for NETWORK or not. So how do I UNCOMMENT the section in the file you mentioned? I'm only able to use the COMMAND PROMPT on this Linux Server.....

Also, how do I configure the USER rights...for MySQL?
0
 
LVL 4

Expert Comment

by:albuitra
ID: 21817651
http://www.experts-exchange.com/OS/Linux/Administration/Q_23473692.html

From the prompt of Linux, try with this
telnet localhost 3306
So you can check if mysql is accepting connections from network

try with
iptables -L -n | grep 3306
0
 
LVL 7

Expert Comment

by:Zippit
ID: 21821879
from the command prompt in the console type:

cat /etc/mysql/my.cnf | less

this will display the config file.  Typically near the top you'll see lines like the following:

[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock

make sure they are uncommented (do not have # in front of them).

Also, look for a line (about 30 lines from the top) that looks like this:

bind-address            = 127.0.0.1

If you have this then MySQL is listening locally only and you will not be able to connect via the network.

Let me know what you find and we'll go from there.
0
 
LVL 7

Expert Comment

by:Zippit
ID: 21821966
here's a good link, details some of the suggestions made in this thread and covers a few others:

http://dev.mysql.com/doc/refman/5.1/en/can-not-connect-to-server.html
0
 
LVL 17

Author Comment

by:MIKE
ID: 21823718
Zippet:

It has this on line 30:

#bind-address            = 127.0.0.1

Thx
M
0
 
LVL 17

Author Comment

by:MIKE
ID: 21823743
albuitra:

This:
telnet localhost 3306

Gave me This:
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
J
5.0.45-Debian_1ubuntu3.1-log¦1Ox/~NLq,uxyvds4IRA,WConnection closed by foreign host.

Your comments please?

Thanks
M
0
 
LVL 17

Author Comment

by:MIKE
ID: 21823765
albuitra:

This:
iptables -L -n | grep 3306

Gave me this:
WARNING: Error inserting x_tables (/lib/modules/<SOMEIPADDRESS>-server/kernel/net/netfilter/x_tables.ko): Operation not permitted
FATAL: Error inserting ip_tables (/lib/modules/<SOMEIPADDRESS>-server/kernel/net/ipv4/netfilter/ip_tables.ko): Operation not permitted
iptables v1.3.6: can't initialize iptables table `filter': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.

Comments please.
Thx
M
0
 
LVL 4

Expert Comment

by:albuitra
ID: 21823933
Try with this
netstat  --protocol=inet  --all | grep 3306
If only shows 127.0.0.1:3306, then only allows connection from localhost
If shows *:3306, then mysql is accepting connections from network

Try the iptables command like root
0
 
LVL 17

Author Comment

by:MIKE
ID: 21823969
This:
netstat  --protocol=inet  --all | grep 3306

Did NOTHING...just when to next command line..nothing was displayed.

What do you mean by this:
"Try the iptables command like root"
0
 
LVL 4

Expert Comment

by:albuitra
ID: 21824003
When you execute the command
iptables -L -n | grep 3306
Are you like a normal user or root ?
If you are like a normal user, please switch to root and then execute

try with
netstat --all | grep 3306
0
 
LVL 7

Accepted Solution

by:
Zippit earned 2000 total points
ID: 21824045
The netstat means that your server is not listening on the network.

You need to uncomment that "bind-address" line in your my.conf

(here's another reference)
http://markbrown.instantspot.com/blog/2007/03/30/Remote-Access-to-mySql-Database
0
 
LVL 17

Author Comment

by:MIKE
ID: 21824060
How do I "switch to Root"..... very NEW to LINUX.
0
 
LVL 4

Expert Comment

by:albuitra
ID: 21824084
su -
0
 
LVL 7

Expert Comment

by:Zippit
ID: 21824099
oh...sorry...uncomment the "bind-address" and change the 127.0.0.1 to your server's IP

So it should be something like the following (assuming your server's IP is 192.168.32.101)

bind-address            = 192.168.32.101

you will need a text editor to do so.  VI can do it...but unless you know it I recommend going with something like joe or nano

if you don't have them then just run

sudo apt-get install joe
(assuming you have sudo access of course)

Once you fire up joe, use CTRL+K,H to see help for control keys.  But it's pretty straightforward.
0
 
LVL 7

Expert Comment

by:Zippit
ID: 21824109
I really don't think it's his iptables if netstat is showing that 3306 isn't being listened on at all.  If it was iptables wouldn't netstat show the 3006 port?
0
 
LVL 17

Author Comment

by:MIKE
ID: 21824147
Whoooo hooo...ok I"m in ZIPPIT...thaks for the LINK..that was the best info I've seen on my error !

Thanks
M
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The DROP (Spamhaus Don't Route Or Peer List) is a small list of IP address ranges that have been stolen or hijacked from their rightful owners. The DROP list is not a DNS based list.  It is designed to be downloaded as a file, with primary intention…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question