How to change default MySQL port in linux?



Share on Google+Share on Google+

Java Coder
How to change default MySQL port in linux?
2 Answer(s)      3 years and 10 months ago
Posted in : Java Beginners

I have a sever and due to some reasons I want to run the MySQL server on the different port and not on the detault port 3306.

How to change the MySQL default port on my Linux box?


View Answers

December 4, 2013 at 5:20 PM


Here are the steps of change the MySQL's default port on Linux based computer.

Step 1:

Loin to your Linux computer as root.

Step 2:

Using vi editor tool open the my.cnf file for editing. Here is the command:

vi /etc/my.cnf

Find the entry:

port       = 3306

Step 3:

Change it to desired port

port       = 3307

or something else.

Save the file and exit the vi editor.

Step 4:

Restart the mysql server using following command:

service mysql restart

After restarting the MySQL server it will start listening on another port.


December 4, 2013 at 5:21 PM


Check the tutorial MySQL default port number and how to change it if you are using windows machine.




Advertisement null