Solved

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

Posted on 2008-06-18
19
7,323 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Do you have a windows based Checkpoint SmartCenter for centralized Checkpoint management?  Have you ever backed up the firewall policy residing on the SmartCenter?  If you have then you know the hassles of connecting to the server, doing an upgrade_…
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

816 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now