Location>code7788 >text

MySQL Compilation and Installation - Kirin V10 x86

Popularity:530 ℃/2024-08-20 13:42:10

Environmental information

Operating System: Kylin Linux Advanced Server V10 (Sword)
Architecture: X86
MySQL Version: 5.7.44

compiling

  • Install the necessary dependency libraries and compilation tools
sudo yum groupinstall 'Development Tools'
sudo yum install cmake ncurses-devel openssl-devel boost-devel
  • Download MySQL Source Code

Download the MySQL source packages from the official MySQL website or GitHub repository.

wget /get/Downloads/MySQL-5.7/mysql-5.7.
tar -xzvf mysql-5.7.
cd mysql-5.7.44
  • Configuring CMake Options

Use CMake to configure MySQL build options. You can customize them as needed, such as specifying the installation directory, disabling unneeded features, and so on.

cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc/mysql \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_BOOST=boost

-DCMAKE_INSTALL_PREFIX: Specifies the MySQL installation directory.
-DMYSQL_DATADIR: Specifies the data storage directory.
-DSYSCONFDIR: Specifies the configuration file directory.
-DWITH_SSL and -DWITH_ZLIB: Specifies to use the system's SSL and Zlib libraries.
-DDEFAULT_CHARSET and -DDEFAULT_COLLATION: Set the default character set and proofreading rules.
-DWITH_BOOST: Specifies the location of the Boost library.

Compilation Failures with Boost Library Errors

Boost is one of the required dependencies for MySQL compilation. In order to continue compiling, CMake needs to know where the Boost library is located.

cure
Choose one of the following two methods to solve this problem:

Method 1: Automatically download and use the Boost library
It is possible to have CMake automatically download and use the Boost library. This is a simple method, and CMake will automatically download and configure the Boost library for you.

cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \\
-DSYSCONFDIR=/etc/mysql \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \\
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost
-DDOWNLOAD_BOOST=1: Let CMake download Boost library automatically.
-DWITH_BOOST=/usr/local/boost: Specify the directory where Boost libraries will be downloaded and stored. You can choose different paths as needed.

Method 2: Manually download and specify Boost library paths
You can also download the Boost library manually and assign its path to CMake.

Download the Boost library:

wget /artifactory/main/release/1.59.0/source/boost_1_59_0.
tar -xzf boost_1_59_0.

Specify the Boost path when configuring CMake:

cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc/mysql \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_BOOST=/path/to/boost_1_59_0

Replace /path/to/boost_1_59_0 with the path where you actually unpacked Boost.

  • Compilation and Installation

After successful configuration, compile and install MySQL using the make and make install commands.

make
sudo make install
  • Initializing the MySQL Data Catalog

After the installation is complete, you need to initialize the MySQL data directory and set the root password.

cd /usr/local/mysql
sudo bin/mysqld --initialize --user=mysql

After the initialization is complete, make a note of the generated temporary root password, which you will later use to log in to MySQL.

  • Configuring MySQL

Create a MySQL configuration file (such as /etc/) and customize it as needed.

sudo cp support-files/ /etc/
  • Starting MySQL

Set up MySQL as a system service and start MySQL.

sudo cp support-files/ /etc//mysql
sudo systemctl enable mysql
sudo systemctl start mysql
  • Setting the root password and security configuration

Log in to MySQL with the temporary password from the initialization and set a new root password.

sudo /usr/local/mysql/bin/mysql_secure_installation

Follow the prompts to complete the security configuration, set the root password, remove the anonymous user, disable remote root login, and so on.

  • Verify Installation

Verify that the installation was successful by logging into MySQL.

/usr/local/mysql/bin/mysql -u root -p

After entering the newly set root password, enter the MySQL command line interface. If you are successful, the MySQL compilation and installation is complete.

The address of the compiled installation package: