CentOS 7.4 Install MySQL 5.7.20 using source package compilation

Source: Internet
Author: User
Tags localhost mysql strong password

yumthe general version of MySQL installed is older, but it runs stably. If you want to try the latest features or you need to specify special features, you need to manually compile the installation.

First, download the installation package (a), first download the MySQL source code, the site is: https://dev.mysql.com/downloads/mysql/:
    1. In the Select Operationg System choice Source Code ;
    2. In the following Select OS Version selection Generic Linux(Architecture Independent) ;
    3. And then the following section can be seen Compressed TAR Archive , click on the back Download ;
    4. Select the bottom of the popup screen No thanks, just start my download to start the download.
      When the download is complete, use the WinSCP directory where you copied the files to the server /usr/local/src .

You can also use the following method to download the source package directly in Linux, in the /usr/local/src directory directly with the wget download:

cd /usr/local/srcwget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20.tar.gz
(b), download boost

Download URL: http://www.boost.org/users/download/
This version of MySQL requires that the boost version is 1.59 and the link is:
Http://www.boost.org/users/history/version_1_59_0.html
The following is a link to the boost 1.59.0, which is /usr/local/src downloaded directly from the directory. wget

http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
second, compile and install (a), install the necessary software dependencies:
-y cmake bison bison-devel libaio-devel gcc gcc-c++ git ncurses-devel
(b), unzip the MySQL source file:
tar -zxvf mysql-5.7.20.tar.gz

Move the boost compression package to the extracted source file directory:

mv boost_1_65_1.tar.gz mysql-5.7.20
(c), enter the MySQL source file directory, create a new configure as a compiled directory, and enter the directory:
cd mysql-5.7.20mkdir configurecd configure
(iv), using CMake to build the compilation environment:
CMake. -dbuild_config=mysql_release-dinstall_layout=STANDALONE-Dcmake_build_type=Relwithdebinfo-Denable_dtrace=OFF-Dwith_embedded_server=OFF-Dwith_innodb_memcached=On-Dwith_ssl=bundled-Dwith_zlib=system-dwith_pam=On-dcmake_install_prefix=/var/mysql/-dinstall_plugindir=  "/var/mysql/lib/plugin"-DDEFAULT_ Charset=utf8-ddefault_collation=utf8_general_ci- dwith_editline=bundled- dfeature_set=community-DCOMPILATION _comment= "MySQL Server (GPL)"-dwith_ Debug=off-dwith_boost=:     

If there is an error compiling, please remove CMakeCache.txt before recompiling:

rm -rf CMakeCache.txt

The following prompt indicates that the build environment was successfully generated:

-- Configuring done-- Generating done
(v), compile with make:
make

When the compilation is complete, the following information appears:

[100%] Building CXX object sql/CMakeFiles/udf_example.dir/udf_example.cc.oLinking CXX shared module udf_example.so[100%] Built target udf_example[100%] Built target my_safe_process
(vi), install MySQL:
install
Third, initialize the database (a), add MySQL User:
-s /sbin/nologin mysql
(ii), create a new database folder and log folder, and change the user to MySQL:
mkdir /mysql_datamkdir /var/mysql/logchown -R mysql:mysql /mysql_data/chown -R mysql:mysql /var/mysql/log
(iii), modify the configuration file
vim /etc/my.cnf

Replace the contents of [mysqld] with the following:

[mysqld]port=3306datadir=/mysql_datalog_error=/var/mysql/log/error.logbasedir=/var/mysql/
(iv) Initialization of the database:
/var/mysql/bin/mysqld  --initialize --user=mysql

To see if the data file is generated:

[[email protected] configure]# ll/mysql_data/total dosage 110620-Rw-r-----.1 MySQL MySQL56October219:auto.cnf-Rw-r-----.1 MySQL MySQL419October219:ib_buffer_pool-Rw-r-----.1 MySQL MySQL12582912October2 :ibdata1-rw-r-----. 1 mysql mysql 50331648 October 2 :ib_logfile0-rw-r-----. 1 mysql mysql 50331648 October 2 :ib_logfile1drwxr-x---. 2 mysql mysql 4096 October 2 19:4 4 Mysqldrwxr-x---. 2 mysql mysql 4096 October 2 19:44 performance_schemadrwxr-x---. 2 MySQL mysql 12288 October 2 19:44 sys              

To see if the log files are generated:

[root@localhost mysql]# ll /var/mysql/log/总用量 4-rw-r-----. 1 mysql mysql 802 10月 2 19:47 error.log
iv. configuration of startup files and environmental changes (i), configure the boot file

1. Copy the startup file from the template file:

cp /var/mysql/support-files/mysql.server /etc/init.d/mysqld

2. Modify the Startup file:

vim /etc/init.d/mysqld

Find the following two lines:

basedir=datadir=

Modified to:

basedir=/var/mysql/datadir=/mysql_data

3. Start MySQL:

[root@localhost mysql]# /etc/init.d/mysqld startStarting MySQL. SUCCESS!

You can see the prompt that has started successfully. Of course you can also use Systemctl to start MySQL, but after execution, there will be no prompt.

[root@localhost ~]# systemctl start mysqld
(b), set up MySQL boot automatically:
[root@localhost ~]# systemctl enable mysqldmysqld.service is not a native service, redirecting to /sbin/chkconfig.Executing /sbin/chkconfig mysqld on
(c), configure the MySQL environment variable:
vim /root/.bash_profile

Locate the following line:

PATH=$PATH:$HOME/bin

Modified to:

PATH=$PATH:$HOME/bin:/var/mysql/bin
(iv), modified root initial password

1. View root the initial password
MySQL does not support logging in with a blank password since 5.7, so the temporary password generated by the program needs to be queried first:

[root@localhost ~]# cat /var/mysql/log/error.log |grep ‘A temporary password‘2017-11-13T06:28:23.096812Z 1 [Note] A temporary password is generated for root@localhost: wa&sk371_,US

Part Bkv,dy after the last line of the colon, O7SS is the initial password.
2. Log in to MySQL and modify the initial password:
Log in to MySQL with the initial password:

[root@localhost ~]# mysql -uroot -pEnter password:

Modify the root password immediately after login:

mysql> alter user ‘root‘@‘localhost‘ identified by ‘your_password‘;Query OK, 0 rows affected (0.00 sec)

Which your_password is the new password you set. The new password should be a strong password, requiring the password to contain uppercase and lowercase letters, numbers, and punctuation, which should be at least 6 digits long.

(v), testing

After setting up, restart the server to see if MySQL starts automatically:

[Root@localhost ~]# PS aux |grep mysqldroot8160.00.11153881716?S14:450:00/bin/sh/var/mysql//bin/mysqld_safe--datadir=/mysql_data--pid-file=/mysql_data/localhost.localdomain.pidmysql10341.017.61122908179688?Sl14:450:00/var/mysql/bin/mysqld--basedir=/var/mysql/--datadir=/mysql_data--plugin-dir=/var/mysql//lib/plugin--user=mysql--log-error=/var/ Mysql/log/error.log--pid-file=/mysql_data/localhost.localdomain.pid--port=3306root 1119 0. 0 0. 0 112676 984 pts/1 r+ 14:46 0:00 grep--color=auto mysqld    

The above information indicates that the whole process of compiling and installing MySQL5.7.20 on CentOS7.4 has been completed manually.

CentOS 7.4 Install MySQL 5.7.20 using source package compilation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.