Home > Database > Mysql Tutorial > body text

How to perform binary installation of mysql

PHPz
Release: 2023-04-19 15:01:12
Original
3208 people have browsed it

MySQL is a commonly used relational database management system that is widely used in various Internet and enterprise-level applications. In order to meet users with different operating systems and needs, MySQL provides a variety of installation methods. Among them, the binary installation method is a more direct and simple method.

This article will introduce how to install MySQL binary on Linux system. Please pay attention to the system version and hardware configuration before installation, and confirm that it matches the download file officially released by MySQL.

Step 1: Download the MySQL software package

First, we need to download the MySQL binary software package suitable for our system from the MySQL official website. After finding the suitable version, we can use the curl command to download it.

$ curl -O https://dev.mysql.com/get/<文件名>.tar.gz
Copy after login

Step 2: Decompress the MySQL software package

Decompression of the MySQL software package can be done using the tar command.

$ tar -xvf <文件名>.tar.gz
Copy after login

This command will generate a folder in the current directory, which contains the MySQL source code and various configuration and description files.

Step 3: Install dependencies

Before installing MySQL, we need to ensure that the following dependencies have been installed in the system:

  1. gcc compiler
  2. cmake
  3. bison
  4. openssl-devel

You can install these dependencies using the following command:

$ sudo yum install gcc cmake bison openssl-devel
Copy after login

Step 4: Create MySQL users and groups

Before installing MySQL, we need to create a MySQL user and group to manage the installation and operation of the MySQL software package.

$ sudo groupadd mysql
$ sudo useradd -g mysql mysql -s /sbin/nologin
Copy after login

Step 5: Compile the MySQL package

Now, we are ready to install MySQL on the Linux system. Please note that the compilation process may take some time.

$ cd <源代码目录>
$ cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
$ make
$ sudo make install
Copy after login

After compilation is completed, the compiled binary file can be placed in the /usr/local/mysql directory.

Step 6: Initialize MySQL

Now, we have installed the MySQL software package, but we still need to perform initialization settings. The following code line is the initialization part of installing MySQL under Linux:

$ sudo mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
Copy after login

After execution, some information will be output, which will include the password of the MySQL root account.

Step 7: Start MySQL

Next, we can start the MySQL service.

$ sudo systemctl start mysql
Copy after login

If you want to automatically start the MySQL service when booting, you can run the following command:

$ sudo systemctl enable mysql
Copy after login

Step 8: Configure MySQL

We need to configure MySQL to suit our use need. Before starting MySQL, you need to make some necessary modifications to the configuration file for the basic configuration.

$ sudo vi /etc/my.cnf
Copy after login

Find the sequence-related content and set the appropriate value, for example:

[mysqld]
skip-name-resolve
server-id=1
binlog_format=ROW
log_bin=mysql-bin
Copy after login

Note: Each time you modify the MySQL configuration file, you need to restart the MySQL service.

$ sudo systemctl restart mysql
Copy after login

Step 9: Test MySQL

Now that MySQL has been installed, we can try to use the mysql command line client to connect to the MySQL server.

$ mysql -u root -p
Copy after login

After entering the password, you should see output similar to this:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.7.12-log MySQL Community Server (GPL)
Copy after login

Now, MySQL for binary installation is ready, and we can happily use it for storage and management All types of data!

The above is the detailed content of How to perform binary installation of mysql. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!