Search This Blog

Saturday, September 8, 2012

How to change default MySQL port in linux

How To Change Mysql Port In Linux

Open and Edit /etc/my.cnf  OR  /opt/lamp/lamp/etc/my.cnf  using your favourite editor.

# vi /etc/my.cnf
# vi /opt/lamp/lamp/etc/my.cnf 

Now find the line Port=3306 (default MySQL port) and change it to :
Port= new port no.   // make sure this port is not used for other     services. (/etc/services)

The below is my system’s my.cnf  file:
user       = root
port       = 3307
socket     = /opt/lampp/var/mysql/mysql.sock
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M

Now save and close my.cnf file and restart MySQL services:
#service mysqld restart
#/opt/lamp/lamp restart

No comments:

Post a Comment