How to install multiple mysql databases under Centos5.2
1. Compile and install the first MySQL 5.1.33
cd /opt/usr/sbin/groupadd mysql/usr/sbin/useradd -g mysql mysql -s /bin/nologin -d /usr/local/mysqltar -zxvf mysql-5.1.33.tar.gzcd mysql-5.1.33/./configure --prefix=/usr/local/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobasemake && make installchmod +w /usr/local/mysqlchown -R mysql:mysql /usr/local/mysqlcp support-files/my-medium.cnf /usr/local/mysql/my.cnfcd ../
Appendix: The following are additional steps. if you want to run the MySQL database on this server, perform the following two steps. If you only want PHP to support MySQL extension libraries and connect to MySQL databases on other servers, you do not need to perform the following two steps.
① Create a data table as a mysql User account:
/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
② Start MySQL (the last & indicates running in the background)
/Bin/sh/usr/local/mysql/bin/mysqld_safe -- defaults-file =/usr/local/mysql/my. cnf & echo "/bin/sh/usr/local/mysql/bin/mysqld_safe -- defaults-file =/usr/local/mysql/my. cnf & ">/etc/rc. localln-s/usr/local/mysql/bin/mysql/sbin/mysql ln-s/usr/local/mysql/bin/mysqladmin/sbin/mysqladminmysqladmin-u root password 1234 -- initialize the root password mysqladmin-u root-p password 456 -- modify the password set by root mysql-u root-p -- use the new password to connect to the database
Add a mysql account
Grant all on *. * to 'mysql3306 '@' % 'identified by 'mysql3306'; -- add user mysql3306 for remote mysql database management
II. Compile and install the second mysql 5.1.33:
Note: You can copy all the installation files of the first mysql instance. to be familiar with the installation process, reinstall it here.
cd /opt/usr/sbin/useradd -g mysql mysql3307 -s /bin/nologin -d /usr/local/mysql3307tar -zxvf mysql-5.1.33.tar.gzcd mysql-5.1.33/./configure --prefix=/usr/local/mysql3307/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobasemake;make installchmod +w /usr/local/mysql3307chown -R mysql3307:mysql /usr/local/mysql3307chmod -R 777 /usr/local/mysql3307cp /usr/local/mysql/share/mysql/my-medium.cnf /usr/local/mysql3307/my.cnf
Modify the configuration file:
Port = 3307 -- modify port socket =/tmp/mysql3307.sock -- modify sock # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3307 socket =/tmp/mysql3307.sock
① Create a data table as a mysql User account:
/usr/local/mysql3307/bin/mysql_install_db --basedir=/usr/local/mysql3307 --datadir=/usr/local/mysql3307/data --user=mysql3307
② Start MySQL (the last & indicates running in the background)
/bin/sh /usr/local/mysql3307/bin/mysqld_safe --defaults-file=/usr/local/mysql3307/my.cnf &echo "/bin/sh /usr/local/mysql3307/bin/mysqld_safe --defaults-file=/usr/local/mysql3307/my.cnf &" >> /etc/rc.local
Note: In the event of warning world-writable config file '/usr/local/mysql3307/my. cnf' is ignored
Solution: chmod 644/usr/local/mysql3307/my. cnf
Mysqladmin-P 3307-S/tmp/mysql3307.sock-u root password 1q2w3e -- initialize the root password mysqladmin-P 3307-S/tmp/mysql3307.sock-u root-p password 1q2w3e -- modify root already set the password/usr/local/mysql3307/bin/mysql-uroot-p-S/tmp/mysql3307.sock
Add a mysql account
Grant all on *. * to 'mysql3307' @ '%' identified by 'mysql3307'; -- add user mysql3307 for remote mysql database management