We all know that there are three ways to install MySQL: RPM Binary Package and actual application source code. The system platform we have installed this time is redhat 5. The following describes the specific solution, I hope this will help you in your future studies.
1. Install MySQL using the RPM package
First, you can download the rpm package of the corresponding version from the installation disc or to the MySQL website as follows:
- MySQL-server-community-5.1.38-0.rhel5.i386.rpm
- MySQL-client-community-5.1.38-0.rhel5.i386.rpm
Then we can use the rpm command to install MySQL:
- rpm -ivh MySQL-server-community-5.1.38-0.rhel5.i386.rpm
- rpm -ivh MySQL-client-community-5.1.38-0.rhel5.i386.rpm
Ii. Install Binary packages
The procedure is as follows:
1. Use root to log on to the system and add MySQL users and groups.
- groupadd MySQL
- useradd -g MySQL MySQL
2. decompress the Binary Package. If the Binary Package is stored in/home/MySQL, decompress the package and add a symbolic link.
- tar xvfz MySQL-5.1.38-linux-i686-glibc23.tar.gz
- ln -s MySQL-5.1.38-linux-i686-glibc23 MySQL
3. Create a system database table in the database directory. -- user indicates that the owner of these databases and tables is the user
- cd MySQL
- ./scripts/MySQL_install_db --user=MySQL
4. Set directory permissions and change the owner of the data directory to MySQL. The owner of files in other directories is root.
- chown -R root:MySQL .
- chown -R MySQL:MySQL data
5. Start MySQL
- ./bin/MySQLd_safe --user=MySQL &
Iii. Install MySQL with source code
1. Use root to log on to the system and add MySQL users and groups.
- groupadd MySQL
- useradd -g MySQL MySQL
2. decompress the source code package and enter the decompressed directory.
- tar xvfz MySQL-5.1.38.tar.gz
- cd MySQL-5.1.38
3. Use the configure tool to compile the source code. here we can use a lot of parameters. For details, see configure -- help. Here we will install MySQL under/usr/local/MySQL.
- ./configuer --prefix=/usr/local/MySQL
- make
- make install
4. select a sample configuration file and copy it to/etc/and rename it my. cnf.
- cp support-files/my-medium.cnf /etc/my.cnf
5. Create a system database table in the database directory. -- user indicates that the owner of these databases and tables is the user
- cd /usr/local/MySQL
- ./bin/MySQL_install_db --user=MySQL
6. Set directory permissions and change the owner of the var directory to MySQL. The owner of other directories and files is root.
- chown -R root .
- chown -R MySQL var
- chgrp -R MySQL .
7. Start MySQL
- ./bin/MySQLd_safe --user=MySQL &
The above content is an introduction to the three MySQL installation methods. I hope you will have some gains.