W3Schools Learner's Blog

W3Schools Programming knowledge summary website

div

12/15/2017

how to change the default port of mysql on CentOS 7

how to change the default 3306 port of mysql on CentOS 7, it's very simple.
step1:You need to edit your my.cnf(vim /etc/my.cnf), add or modify the line. 
  1. port=3306 
change the default port of mysql from 3306 to 3388, as follows.
  1. [mysqld]
  2. datadir=/var/lib/mysql
  3. socket=/var/lib/mysql/mysql.sock
  4. user=mysql
  5. # Disabling symbolic-links is recommended to prevent assorted security risks
  6. symbolic-links=0
  7. port=3388
  8. [mysqld_safe]
  9. log-error=/var/log/mysqld.log
  10. pid-file=/var/run/mysqld/mysqld.pid
step2:Restart mysql server on CentOS 7.
  1. # systemctl restart mysqld
step3:Check what port mysql is running on. run netstat -ntlp command.
  1. [root@VM_230_32_centos ~]# netstat -ntlp
  2. Active Internet connections (only servers)
  3. Proto Recv-Q Send-Q Local Address         Foreign Address       State       PID/Program name   
  4. tcp        0      0 0.0.0.0:3388          0.0.0.0:*             LISTEN      6944/mysqld         
  5. tcp        0      0 0.0.0.0:80            0.0.0.0:*             LISTEN      6998/httpd          
  6. tcp        0      0 0.0.0.0:4369          0.0.0.0:*             LISTEN      30342/epmd          
  7. tcp        0      0 0.0.0.0:22            0.0.0.0:*             LISTEN      1062/sshd           
  8. tcp        0      0 127.0.0.1:25          0.0.0.0:*             LISTEN      1154/master
thanks!

1 comment:

  1. Amazing post.Thanks for your details and explanations..I want more information from your side.Thank you

    Guest posting sites
    Education

    ReplyDelete

Note: only a member of this blog may post a comment.