detailed steps:
1. First, make a copy of the my.cnf configuration file. To open several ports, you need to copy several copies and of course rename them.
Such as:
cp /etc/my.cnf /etc/my3306.cnf
cp /etc/my.cnf /etc/my3307.cnf
cp /etc/my.cnf /etc/my3308.cnf
2. Modify the my_1.cnf, my_2.cnf, my_3.cnf files to change the default port 3306 to 3307 3308 3309.
Such as:
[client]
port = 3308
socket = /tmp/mysql3308.sock
default-character-set=UTF
[mysqld]
port = 3308
socket = /tmp/mysql3308.sock
basedir=/usr/local/mysql
datadir=/www/mysqldata8
3. Create a database to specify a directory to store data
mkdir /www/mysqldata3306
mkdir /www/mysqldata3307
mkdir /www/mysqldata3308
4. Initialize the database
/usr/local/mysql/scripts/mysql_install_db --datadir=/www/mysqldata3306/ --user=mysql --basedir=/usr/local/mysql
/usr/local/mysql/scripts/mysql_install_db --datadir=/www/mysqldata3307/ --user=mysql --basedir=/usr/local/mysql
/usr/local/mysql/scripts/mysql_install_db --datadir=/www/mysqldata3308/ --user=mysql --basedir=/usr/local/mysql
5. To start mysql, specify the .cnf file and directory to start
/usr/local/mysql/bin/mysqld_safe --defaults-extra-file=/etc/my3306.cnf --datadir=/www/mysqldata3306 --user=mysql &
/usr/local/mysql/bin/mysqld_safe --defaults-extra-file=/etc/my3307.cnf --datadir=/www/mysqldata3307 --user=mysql &
/usr/local/mysql/bin/mysqld_safe --defaults-extra-file=/etc/my3308.cnf --datadir=/www/mysqldata3308 --user=mysql &
6. Stop MYSQL, the corresponding sock file.
/usr/local/mysql/bin/mysqladmin -uroot -S /tmp/mysql3308.sock shutdown
7. Log in to mysql
mysql -S /tmp/mysq3308.sock -P 3308
8. You can query all currently opened mysql services
chkconfig --list | grep on
appendix:
(1) Query linux related installation information ps -ef|grep mysql