Open source MySQL binary package installation

There are many ways to install the MySQL database, and the most commonly used are binary installation and source installation. The binary installation method includes the rpm version and the glibc version. The rpm version is compiled under a specific linux version. If your linux version matches, you can install it. For example, for the rpm package compiled for RedHat6 or RedHat7, download the corresponding installation. Can. There is another binary installation package compiled based on a specific glibc version, which is basically applicable to most linux versions. Now I record the installation process based on the glibc binary package (ubuntu16.04 64-bit environment):

1. Download (https://www.mysql.com/downloads/) the free version of the official website community, if the network speed is slow, you can download it from the Sohu software mirror website (http://mirrors.sohu.com/mysql/MySQL -5.7/), I choose the mysql-5.7.17-linux-glibc2.5-x86_64.tar version;

2. cd /usr/local/ ##Enter the local directory

3. cp  mysql-5.7.17-linux-glibc2.5-x86_64.tar  /usr/local/ ##Copy mysql and compress it to the local directory

3. cd /usr/local/ ##Enter the local directory

4、tar -xvf mysql-5.7.17-linux-glibc2.5-x86_64.tar  ##解包mysql

5. mv  mysql-5.7.17-linux-glibc2.5-x86_64  mysql ##Rename mysql directory

6, groupadd mysql ##Add a mysql group

7. useradd -r -g mysql mysql ##Add a user

8. chown -R mysql mysql/ ##Authorize the mysql directory to the mysql user

9. mkdir /usr/local/mysql/data ##Create mysql data directory

10. chown -R mysql:mysql /usr/local/mysql/data ##Authorize the data directory to the mysql user in the mysql group

11. The chgrp -R mysql /usr/local/mysql/data ##chgrp command can use the group name or group identification code to change the group to which a file or directory belongs. (-R: Process all files in the specified directory and its subdirectories) The permission is super user.

12. cd /usr/local/mysql ##Enter the mysql directory

13. cp support-files/my-default.cnf ./my.cnf ##Copy the my-default.cnf file in the support-files directory to the my.cnf file in the current directory

14. vi /usr/local/mysql/my.cnf ##Edit my.cnf file

basedir = /usr/local/mysql ##basedir is the path of mysql

datadir = /usr/local/mysql/data ##datadir is the data package of mysql

socket = /tmp/mysql.sock

15. cp -fr my.cnf /etc/my.cnf ##Copy the my.cnf file to the etc directory (replace if there is one in the etc directory)

16. /usr/local/mysql / bin/mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql # Initialize the database

Explanation of command parameters:

--defaults-file : Make MySQL configuration file path

--initialize : Initialize random password, note that the initialized password is an expired password, you need to change the password after login

--user: specify the account

After the command is executed, a random password will be given at the end of the command prompt, be sure to remember to record this password.

17. support-files/mysql.server start #Start mysql server

shell > bin/mysql -u root -p

Enter password: # Enter the random password just now to link to the database

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY  '新密码';

 

So far the binary installation is complete! ! !

The process and principle of compilation and installation are almost the same as those of binary installation. The biggest difference is that when compiling and installing, we need to download the source code for manual compilation, while binary installation does not require us to manually compile;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326073074&siteId=291194637