Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm very new to Ubuntu. I couldn't able to connect to mysql via my programming language.

I know all my property file in my code is correct. But still I couldn't able to connect to mysql. I guess my firewall is blocking me out.

I have ufw firewall installed, how do I enable 3306 port in that?

I tried these steps but doesn't get the solution.

Thanks in advance.

share|improve this question
Why do you guess your firewall is blocking you out? How are you trying to connect to mysql? Copy-paste the commands you tried and the complete error messages. – Gilles Aug 11 '12 at 14:57
up vote 5 down vote accepted

You can use these commands to allow port 3306 through UFW

 sudo ufw allow out 3306/tcp  

 sudo ufw allow in 3306/tcp   

And to check that the rules have been added

 sudo ufw status
share|improve this answer

Create the file /etc/ufw/applications.d/mysql-server and include the following content.

title=MySQL Relational Database Server
description=MySQL is a Relational Database Server commonly used in a variety of ways including to host the database of websites

Run command: sudo ufw allow MySQL

You should be good to go. Feel free to give it a better title and description. I just tossed something in quick like.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.