You can change the MySQL port in the /etc/my.cnf file:
port=6446
Then restart MySQL:
/etc/init.d/mysql restart
I did this change on my machine as a test and had no issue whatsoever changing it. Here's the results showing it began listening on that port after the change:
[root@itchy:~] # ps aux|grep mysql
root 10660 0.3 0.1 6744 1076 pts/0 S 07:29 0:00 /bin/sh /usr/bin/mysqld_safe
--datadir=/var/lib/mysql --pid-file=/var/lib/mysql/hostname.com.pid
mysql 10805 3.8 15.5 1510596 155372 pts/0 Sl 07:29 0:00 /usr/sbin/mysqld
--basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/hostname.com.pid
--skip-external-locking --port=6446
Notice the --port=6446 part in the ps aux return?
[root@itchy:~] # lsof -i :6446
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
mysqld 10805 mysql 12u IPv4 60642652 TCP *:6446 (LISTEN)
[root@itchy:~] # netstat -an|grep :6446
tcp 0 0 0.0.0.0:6446 0.0.0.0:* LISTEN
As a final note, I did also check PhpMyAdmin and cPanel > MySQL Databases area. Both were working for me after this change, so this did not impact the various cPanel areas working on my server.
how to change port for mysql
最新推荐文章于 2022-01-24 22:37:28 发布