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
Step 2: Decompress the MySQL software package
Decompression of the MySQL software package can be done using the tar command.
$ tar -xvf <文件名>.tar.gz
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:
You can install these dependencies using the following command:
$ sudo yum install gcc cmake bison openssl-devel
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
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
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
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
If you want to automatically start the MySQL service when booting, you can run the following command:
$ sudo systemctl enable mysql
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
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
Note: Each time you modify the MySQL configuration file, you need to restart the MySQL service.
$ sudo systemctl restart mysql
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
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)
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!