In this post we will see how to change MySQL instance port.
By default MySQL will be listening to port 3306. From security perspective it’s not a good idea to run your instance with default port. To change the port all you have to do is edit the configuration file.
Windows -> my.ini
Linux -> my.cnf
How to locate your configuration file?
In windows
-Open services.msc console. Look for your MySQL service
-Right click MySQL service and open ‘Properties’.
-Under ‘Path to execute’ you can find the my.ini location
"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.6\my.ini" MySQL56
-Open the configuration file and search for port, by default its 3306
-I have changed it to 3333.
You have to restart MySQL service to make the changes effective.
Let’s check if MySQL instance is listening to 3333 port. To check the port you can use below command from MySQL client.
SHOW VARIABLES WHERE VARIABLE_NAME LIKE 'PORT';
In Linux
Configuration will be located in /etc/mysql/my.cnf. You have to open and follow the same process.
Note: Take backup of configuration file before making any changes
Cheers,
Naveen
By default MySQL will be listening to port 3306. From security perspective it’s not a good idea to run your instance with default port. To change the port all you have to do is edit the configuration file.
Windows -> my.ini
Linux -> my.cnf
How to locate your configuration file?
In windows
-Open services.msc console. Look for your MySQL service
-Right click MySQL service and open ‘Properties’.
-Under ‘Path to execute’ you can find the my.ini location
"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.6\my.ini" MySQL56
-Open the configuration file and search for port, by default its 3306
-I have changed it to 3333.
You have to restart MySQL service to make the changes effective.
Let’s check if MySQL instance is listening to 3333 port. To check the port you can use below command from MySQL client.
SHOW VARIABLES WHERE VARIABLE_NAME LIKE 'PORT';
In Linux
Configuration will be located in /etc/mysql/my.cnf. You have to open and follow the same process.
Note: Take backup of configuration file before making any changes
Cheers,
Naveen
No comments:
Post a Comment
Please share your thoughts