Current location - Trademark Inquiry Complete Network - Trademark registration - How to install and deploy MySQL database system in Linux environment
How to install and deploy MySQL database system in Linux environment

How to install and configure the mysql database under Linux

About this article

This article will take MySQL 5.0.51 as an example and CentOS 5 as the platform to describe MySQL Database installation and setup.

2. About MySQL

MySQL is the most popular open source SQL database management system, which is developed, published and supported by MySQL AB. MySQL AB, a commercial company founded by MySQL developers, is a second-generation open source company that uses a successful business model to combine open source values ??and methodologies. MySQL is a registered trademark of MySQL AB.

MySQL is a fast, multi-threaded, multi-user and robust SQL database server. MySQL Server supports the use of mission-critical, heavy-load production systems, and can also be embedded in a mass-deployed software.

The official pronunciation of MySQL is "My Ess Que Ell", not "My sequel". But you can also use "My sequel" and other dialects.

MySQL website (f, my-medium.cnf, my-large.cnf, my-huge.cnf), choose the one that is close to your environment and copy it to the /etc directory, and make appropriate Modify. For detailed information about the mysql configuration file, please refer to the author's other articles or the official mysql documentation.

In this example, select my-medium.cnf and execute the following command to copy it to the /etc directory:

cp ./support-files/my-medium.cnf /etc/my.cnf

3.1.8 Initialize authorization table

Execute the following command to initialize authorization Table:

./scripts/mysql_install_db --user=mysql

3.1.9 Change the owner and permissions of the mysql data directory

The default database file saving directory is The var directory under the installation directory. When executing the configure command, you can specify a different directory through the --localstatedir parameter. The example in this article is the default location.

chown -R mysql.mysql /usr/local/mysql/var

chmod -R 700 /usr/local/mysql/var

3.1.10 Set the auto-start service control script at boot

Execute the following command to copy the startup script to the resource directory:

cp ./support-files/mysql.server /etc/rc.d/init .d/mysqld

Execute the following command to increase the execution permission of the mysqld service control script:

chmod x /etc/rc.d/init.d/mysqld

Execute the following command to add the mysqld service to the system service:

chkconfig --add mysqld

Execute the following command to check whether the mysqld service has taken effect:

chkconfig --list mysqld

The command output is similar to the following:

mysqld 0: off 1: off 2: on 3: on 4: on 5: on 6: off

p>

indicates that the mysqld service has taken effect and will automatically start when the system starts at run levels 2, 3, 4, and 5. You can use the service command to control the start and stop of mysql in the future.

Start the mysqld service:

service mysqld start

Stop the mysqld service:

service mysqld stop

Execute Run the following command to turn off auto-start at boot:

chkconfig mysqld off

Execute the following command to change the run level of auto-start to 3 or 5:

chkconfig --level 35 mysqld on

3.1.11 Add the mysql bin directory to the PATH environment variable

Edit the /etc/profile file:

vi /etc/ profile

Add the following two lines at the end of the file:

PATH=$PATH:/usr/local/mysql/bin

export PATH

Execute the following command to make the changes take effect:

. /etc/profile

3.2 Installation in binary package mode

3.2.1 From the installation media Installation

Mysql binary package has been included in the installation media of CentOS 5. You can install the following three rpm packages directly from the installation media:

mysql-5.0.22-2.1.0.1 .i386.rpm

mysql-devel-5.0.22-2.1.0.1.i386.rpm

mysql-server-5.0.22-2.1.0.1.i386.rpm

p>

The file names of different versions are different, please pay attention to the distinction.

Execute the following command to install:

rpm -iUvh mysql-5.0.22-2.1.0.1.i386.rpm

rpm -iUvh mysql-devel- 5.0.22-2.1.0.1.i386.rpm

rpm -iUvh mysql-server-5.0.22-2.1.0.1.i386.rpm

3.2.2 Install via yum

If the machine you are installing can connect to the Internet at this time, the author recommends using the yum command to simplify the installation process:

yum install mysql-server mysql-devel mysql

Yum will automatically find the latest binary package of the software you specify from the centos mirror site, and check the software package dependencies. When installing the software, it will automatically install its dependent software packages.