binary install MySQL


First, the difference between the three installation methods

Source installation

        Download the source code compression package by yourself, execute config, make, make install to complete the compilation and installation, and the directory parameters in it are completely customized by yourself. After these operations are completed, you need to modify the database configuration file, modify the permissions, and then complete the initial installation;

Binary free compilation and installation

        The difference from the source installation is that the operations of config and make have been completed. Decompressing the binary installation package is equivalent to the make install step of the source installation. The subsequent steps are the same as the source installation, except that the configuration of those directory parameters should follow the default. /etc/local/mysql/ to handle;

rpm/yum install

        In this installation method, the MySQL binary installation package, the modification of the database configuration file, and the initial installation have been integrated into the rpm package. All we need to do is to install the rpm package, and those series of operations will be automatically completed for us, and the installation is successful. After that, you can directly start the database service and then use it.


Second, binary installation of MySQL

You will find out how I installed mariadb. Since the open source MySQL was acquired by Oracle, the founder of MySQL has redeveloped an open source database mariadb. In fact, mariadb and MySQL operate exactly the same. The default database in CentOS7 is mariadb. , but the command and configuration file parameters in the system to open data are still MySQL, so I use MySQL to refer to it in general.

        ① Download the binary installation package, the address of my server is ftp://172.18.0.1/pub/Sources/m28/mariadb-10.2.14-linux-x86_64.tar.gz,

[root@CentOS7 ~]# cd /usr/local/src/
[root@CentOS7 src]# pwd
/usr/local/src
[root@CentOS7 src]# wget -q ftp://172.18.0.1/pub/Sources/m28/mariadb-10.2.14-linux-x86_64.tar.gz

Download the binary installation package to the /usr/local/src/ directory, -q downloads it silently

        ② Unzip the binary installation package to the /usr/local/ directory

[root@CentOS7 src]# tar -zxv -f mariadb-10.2.14-linux-x86_64.tar.gz -C /usr/local/

After that, the mariadb-10.2.14-linux-x86_64 directory will be generated in the /usr/local/ directory

        ③ Rename the generated directory to mysql. The reason for this change is that the directory specified in the configuration file is /usr/local/mysql. This is the case for binary installation. We must install the directory specified when compiling. Changing the directory name is just one way, of course, you can also establish a soft link ln -s mariadb- 10.2.14-linux-x86_64 mysql.

[root@CentOS7 src]# cd /usr/local
[root@CentOS7 local]# mv mariadb-10.2.14-linux-x86_64 mysql

        ④ Create user mysql, group mysql

[root@CentOS7 ~]# groupadd mysql
[root@CentOS7 ~]# useradd -g mysql mysql
[root@CentOS7 ~]# id mysql
uid=1002(mysql) gid=1002(mysql) groups=1002(mysql)

        ⑤ Modify the permissions of all files in the /usr/local/mysql/ directory

[root@CentOS7 ^]# cd /usr/local/
[root@CentOS7 local]# chmod -R mysql.mysql mysql/

blob.png

        ⑥ Modify the database configuration file. Here I copy the provided template to /etc/my.cnf, and then execute the database initialization script to complete the initial installation of the database.

[root@CentOS7 ~]# cd /usr/local/mysql/support-files
[root@CentOS7 support-files]# cp my-large.cnf /etc/my.cnf
[root@CentOS7 ~]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql

        ⑦ Start the mysqld service, the software provides an executable file to start the service.

[root@CentOS7 ~]# /usr/local/mysql/bin/mysqld_safe &

Because this command will always occupy the terminal, use & to switch the process to the background

blob.png

        ⑧ If you start the mysqld service in this way, it will always occupy the terminal, so we can change mysqld to service startup mode, that is, you can use service xxx start to start

[root@CentOS7 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld

        ⑨ At this point, the database can be used normally, but the root password is not set, and anonymous users can log in. For security reasons, the following commands can be executed        

[root@CentOS7 ~]# /usr/local/mysql/bin/mysql_secure_installation

Perform database security settings.



Guess you like

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