1, create multiple MySQL database directory
Copy Code code as follows:
mysql_install_db--datadir=/data/mysql_3307
2, set the database directory permissions
Copy Code code as follows:
3, copy, set my.cnf
Copy Code code as follows:
CP XXX/MY.CNF/DATA/MYSQL_3307/MY.CNF
Add MY.CNF
Copy Code code as follows:
Log-error =/data/mysql_3307/localhost.localdomain.err
Pid-file =/data/mysql_3307/localhost.localdomain.pid
4. Add Startup script:
Copy Code code as follows:
#!/bin/ti
Rundir= ' pwd '
Datadir= $rundir
cnf= $rundir "/MY.CNF"
echo "Server path: $rundir"
echo "Data path: $datadir"
echo "CNF: $cnf"
/usr/local/mysql/bin/mysqld_safe/
--defaults-file= "$CNF"/
--pid-file= "$rundir"/mysql.pid/
--datadir= "$datadir"/
--socket= "$rundir"/mysql.sock/
&
5, Ok,chmod a+x my.cnf,./my.cnf, start
6, Ok, start normal, as shown in the figure above.
Problems that you may encounter:
1)/usr/local/mysql/libexec/mysqld:file './mysql-bin.index ' not Found (errcode:13)
The reason is that the 2nd step is not performed and the user group permissions are set for the database Data folder;
2 Can ' t find messagefile '/data/mysql_3307/share/mysql/english/errmsg.sys '
You need to configure the path of the language in MY.CNF and add the following: Language =/usr/local/mysql/share/mysql/english
3 MySQL is not connected to the MySQL server
Note that MySQL indicates the path to the configuration file, such as MYSQL–DEFAULTS-FILE=/DATA/MYSQL_3307/MY.CNF. You need to check that the Client.socket file is correct in the my.cnf file.