Home > Database > Mysql Tutorial > centos mysql compilation and installation

centos mysql compilation and installation

WBOY
Release: 2023-05-23 10:57:37
Original
704 people have browsed it

CentOS is one of the most popular Linux operating systems in the world, and MySQL is currently the most widely used relational database in the world. Combining the two can create extremely high resource utilization and excellent performance, which is also an issue that more and more developers are paying attention to in recent years. This article will introduce the CentOS MySQL compilation and installation process to help beginners easily create an efficient database system.

1. System environment installation

Before officially starting the installation, you need to download the CentOS system according to your own needs and download the MySQL installation package from official or other sources. Before operation, you need to ensure that the system has installed the required compiler and development dependencies. These environments include the following:

yum -y install gcc gcc-c++ ncurses-devel perl perl-devel automake make
Copy after login

The above command will install the compiler, development library and other necessary dependencies. , so that the MySQL database software can be compiled and installed smoothly.

2. Download and configure the MySQL software package

In the process of downloading the MySQL software, you need to select different versions according to your own needs. At the same time, you need to ensure the integrity of the software package to avoid installation errors. Various problems arise during the process. In order to ensure the integrity of the software package, you can use the following command to verify it:

md5sum mysql-5.7.33.tar.gz
Copy after login

If the verification code is different from the official one, it means that the software package has been tampered with and needs to be re-downloaded and checked. After the download is complete, you need to unzip the MySQL software package to a new directory to facilitate configuration and compilation:

tar zxvf mysql-5.7.33.tar.gz  
cd mysql-5.7.33/
Copy after login

Next, you can run the configure command for configuration. When installing CentOS, the default data directory is located under /var/lib/mysql. You can modify the default directory by using the following command:

./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charsets=all --enable-thread-safe-client --enable-assembler --with-ssl=/usr/local/ssl --with-embedded-server --with-plugins=innobase,myisam --localstatedir=/var/lib/mysql --sysconfdir=/etc/mysql --datadir=/var/lib/mysql
Copy after login

In this command, --prefix is ​​used to set the MySQL installation directory, - -with-ssl is used to specify the path to the SSL library, and other parameters are used to specify compilation options and plug-ins, etc. After the configuration is complete, we can start compilation and installation.

3. Compile and install MySQL

Before compiling and installing, you need to ensure that GCC and C compiler have been installed in the system, otherwise you will not be able to proceed to the next step. You can use the following Command to install:

yum install gcc-c++
Copy after login

Next, you can use the make command to compile:

make
Copy after login

If the compilation is correct, you can use the make install command to install:

make install
Copy after login

At this time, MySQL has been successfully installed and started. You can use the following command to test whether the startup is successful:

service mysql start
Copy after login

If MySQL can be started successfully, it means that we have completed all the processes of compiling and installing CentOS MySQL. If you encounter problems during the installation process, you can seek help and support on the official website or in the open source community.

4. Database initialization

After MySQL is installed and started successfully, we need to initialize the database so that the system can be used normally. You can use the following command to initialize:

mysqld --initialize --user=mysql --datadir=/var/lib/mysql
Copy after login

Among them, the --user parameter is used to specify the user of the MySQL service, and the --datadir parameter is used to specify the data directory. After the initialization is completed, you can use the following command for testing:

mysql -u root -p
Copy after login

At this point, we have successfully completed the entire process of compiling and installing CentOS MySQL and initialized the database. In actual applications, we still need to perform more in-depth configuration and adjustments based on specific scenarios to adapt to different business needs and improve system performance and stability.

The above is the detailed content of centos mysql compilation and installation. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template