Complete tutorial on MySQL5.7 compilation and installation

Source: Internet
Author: User

MySQL compilation and installation has never been deprecated. The reason is simple. The dependency is complex and error-prone. In short, it is troublesome. However, due to the need to compile and install these days, I was forced to read the relevant documents and found that the current MySQL installation is very simple and easy.

Start now.

Everything starts with necessary dependencies.

Yum install-y gcc-c ++ ncurses-devel perl
In this article, the system is CentOS 7. The software package managers of different systems may have different usage, but the requirements are similar. Please prepare gcc ++ ncurses and perl-related compilers or dependent libraries.
Necessary file preparation:

Mysql 5.7.10 (include boost headers) http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.10.tar.gz

Cmake 3.4.1 https://cmake.org/files/v3.4/cmake-3.4.1.tar.gz
Install cmake first, so decompress the downloaded cmake 3.4.1 compilation and installation as follows:

Tar-xzvf cmake-3.4.1.tar.gz
Cd cmake-3.4.1
./Bootstrap
Make & make install

After installing cmake, start the MySQL compilation and installation steps. First, add the system account corresponding to MySQL to ensure that the local file permission is assigned:

Groupadd mysql
Useradd-r-g mysql

Create a database Directory:

Mkdir-p/var/mysql/data
Chown mysql: mysql/var/mysql/data

Start preparing the compilation installation, decompress the mysql-boost-5.7.10.tar.gz and enter its decompressed mysql-5.7.10 directory, where execute:

Cmake \
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_UNIX_ADDR =/usr/local/mysql. sock \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_ARCHIVE_STORAGE_ENGINE = 1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE = 1 \
-DMYSQL_DATADIR =/var/mysql/data \
-DMYSQL_TCP_PORT = 3306 \
-DWITH_BOOST = boost

In addition to the above parameters, there are many other compilation and installation parameters. If you need to know the specific meaning of each parameter or the default value of the parameter, you can refer to the MySQL official website documentation, here is the reference address for this version: http://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html
After executing the cmake configuration process, you need to start preparing the longest compilation process. Based on the configurations of different machines, the time is about 2 hours (more than 4 hours in low configuration ). You are familiar with the following operations: make & make install.

After completing the preceding steps, you must change the owner of the mysql installation directory. For example, if the directory we installed is/usr/local/mysql, run the following command:

Chown-R mysql: mysql/usr/local/mysql

Modify the directory owner. Copy a default configuration file.

Cp/usr/local/mysql/support-files/my-default.cnf/etc/my. cnf

If you are prompted to overwrite an existing file, overwrite it.

Then perform database initialization,

/Usr/local/mysql/bin/mysqld -- initialize -- user = mysql,

At this time, the database will be initialized and a database root account will be created. However, it should be noted that, unlike before, this account has a default password, and the initialization password will be output on the screen during initialization, if you miss it, you can view/root /. mysql_secret to view the default password.

Run cp/usr/local/mysql/support-files/mysql. server/etc/init. d. Copy the mysql service startup script and run service mysql. start mysql.

Finally, enter/usr/local/mysql/bin/mysql-r root-p and press enter.

Set password = password ('your password ');

To change the default password

Now, the basic installation process is complete! You can add mysql to enable startup as needed, or add files under/usr/local/mysql/bin to the PATH environment variable. For more usage instructions, see the official documentation, write carefully.

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.