mysql實現在非默認路徑中運行的方法
1.首先,將3308端口中的數據庫文件保存到非默認路徑中;
如將數據庫文件保存到/data1中
#mkdir /data1/mysql_3308#mkdir /data1/mysql_3308/data
#chown -R mysql:mysql /data1/mysql_3308
2.將my.cnf配置文件復制到mysql_3308目錄中
#vi /data1/mysql_3308/my.cnf
3.打開my.cnf配置文件,在文件中進行以下修改
[client]character-set-server = utf8
port = 3308
socket = /tmp/mysql_3308.sock
[mysqld]
user = mysql
port = 3308
socket = /tmp/mysql_3308.sock
basedir = /usr/local/mysql
datadir = /data1/mysql_3308/data
log-error = /data1/mysql_3308/mysql_error.log
pid-file = /data1/mysql_3308/mysql.pid
4.my.cnf配置文件修改好后,對數據庫進行初始化
#/usr/local/mysql/bin/mysql_install_db --defaults-file=/data1/mysql_3308/my.cnf --datadir=/data1/mysql_3308/data
5.數據庫初始化后,啟動3308端口的mysql服務即可
#/usr/local/mysql/bin/mysqld_safe --defaults-file=/data1/mysql_3309/my.cnf &