1、创建数据文件
mkdir /var/lib/mysql_3307 mysql_install_db --datadir=/var/lib/mysql_3307 --user=mysql
2、给数据文件赋予mysql用户与用户组
chown -R mysql.mysql /var/lib/mysql_3307
3、拷贝配置文件
cp /etc/my.cnf /etc/my_3307.cnf
4、修改配置文件
[client] #password = your_password port = 3307 socket = /var/lib/mysql_3307/mysql_3307.sock # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3307 socket = /var/lib/mysql_3307/mysql_3307.sock datadir=/var/lib/mysql_3307
5、启动mysql
/usr/bin/mysqld_safe --defaults-file=/etc/my_3307.cnf --user = mysql &
6、检查是否启动成功
[root@test-206 ~]# netstat -ntlp tcp 0 0 :::3306 :::* LISTEN 3919/mysqld tcp 0 0 :::3307 :::* LISTEN 15027/mysqld
7、修改密码
mysqladmin -uroot -S /tmp/mysql_3307.sock password 123456
如果没有发现你要的端口号mysql实例,可以检查下/var/lib/mysql_3307/主机名.err文件,排除问题