Install multiple mysql database configuration details under Centos 5.2

  • 2020-06-23 02:05:36
  • OfStack

1. Compile and install MySQL 5.1.33


cd /opt

/usr/sbin/groupadd mysql

/usr/sbin/useradd -g mysql mysql -s /bin/nologin -d /usr/local/mysql

tar -zxvf mysql-5.1.33.tar.gz

cd 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=innobase

make && make install

chmod +w /usr/local/mysql

chown -R mysql:mysql /usr/local/mysql

cp support-files/my-medium.cnf /usr/local/mysql/my.cnf

cd ../


Attached: The following are additional steps to follow if you want to run the MySQL database on this server. If you simply want PHP to support the MySQL extension library and be able to connect to an MySQL database on another server, the following two steps do not need to be performed.

Establish data table as mysql user account:


/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

, start MySQL (last & Means 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.local

ln -s /usr/local/mysql/bin/mysql /sbin/mysql 

ln -s /usr/local/mysql/bin/mysqladmin /sbin/mysqladmin


mysqladmin -u root password 1234 -- Initialize the root password 

mysqladmin -u root -p password 456 -- Modify the root A password has been set 

mysql -u root -p         -- Connect to the database with the new password 



Add mysql account


grant all on *.* to 

'mysql3306'@'%' identified by 'mysql3306';     -- Add user mysql3306 For remote administration mysql The database 

2. Compile and install the second mysql 5.1.33:


Note: You can copy the installation file of the first mysql and re-install it again to get a feel for the installation process


cd /opt

/usr/sbin/useradd -g mysql mysql3307 -s /bin/nologin -d /usr/local/mysql3307

tar -zxvf mysql-5.1.33.tar.gz

cd 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=innobase

make;make install

chmod +w /usr/local/mysql3307

chown -R mysql3307:mysql /usr/local/mysql3307

chmod -R 777 /usr/local/mysql3307

cp /usr/local/mysql/share/mysql/my-medium.cnf /usr/local/mysql3307/my.cnf


Modify the configuration file:


port = 3307                   -- Modify the port 

socket = /tmp/mysql3307.sock       -- Modify the sock

# Here follows entries for some specific programs

# The MySQL server

[mysqld]

port = 3307

socket = /tmp/mysql3307.sock

Establish data table as mysql user account:


/usr/local/mysql3307/bin/mysql_install_db --basedir=/usr/local/mysql3307 --datadir=/usr/local/mysql3307/data --user=mysql3307

, start MySQL (last & Means 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: if a warning world - writable config file '/ usr/local/mysql3307 / my cnf' is ignored

Solution: 644 / chmod 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 the root A password has been set 

/usr/local/mysql3307/bin/mysql -uroot -p -S/tmp/mysql3307.sock


Add the mysql account


grant all on *.* to 

'mysql3307'@'%' identified by 'mysql3307';     -- Add user mysql3307 For remote administration mysql The database 


Related articles: