CentOS 6.6 source code compilation and installation of MySQL 5.7.18 tutorial detailed explanation

CentOS 6.6 source code compilation and installation of MySQL 5.7.18 tutorial detailed explanation

1. Add users and groups

1. Add mysql user group

# groupadd mysql

2. Add mysql user

# useradd -g mysql -s /bin/nologin mysql -M

2. Check whether MySQL is installed in the system. If installed, uninstall it

# rpm -qa | grep mysql
mysql-libs-5.1.73-3.el6_5.x86_64
# rpm -e mysql-libs-5.1.73-3.el6_5.x86_64 --nodeps

3. Install required dependency packages

# yum -y install wget gcc-c++ ncurses-devel cmake

4. Installation

1. Download the latest version of MySQL

Go to http://dev.mysql.com/downloads/mysql/ and select Generic Linux under Source Code. Select MySQL with boost library to download. MySQL5.7 has requirements for the boost library. Choosing one with the boost library will avoid some pitfalls.

# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.18.tar.gz

2. Unzip and install

# tar xf mysql-boost-5.7.18.tar.gz
# cd mysql-5.7.18
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DWITH_BOOST=boost/boost_1_59_0
# make && make install

MySQL will be installed in the /usr/local/mysql directory.

3. Enter the installation directory and create a data directory

# cd /usr/local/mysql
# mkdir data

4. Modify the /usr/local/mysql directory permissions

# chown -R mysql. /usr/local/mysql

5. Initialize the database

# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

Note:

1. The previous version of mysql_install_db was in mysql_basedir/script, and 5.7 is placed in the mysql_install_db/bin directory and has been abandoned.
2. "--initialize" will generate a random password (~/.mysql_secret), while "--initialize-insecure" will not generate a password
3.--datadir There should be no data files in the target directory
4. After using the --initialize parameter, be sure to remember the generated password, otherwise you will not be able to log in to the database.

6. Copy the startup file to /etc/init.d/ and re-command it as mysqld

# /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

7. Create a configuration file

After installation, I found that there was no my.cnf configuration file, so I created one manually.

# vim /etc/my.cnf
[mysqld]
basedir =/usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
socket = /tmp/mysql.sock
[client]
socket=/tmp/mysql.sock

8. Start mysql

# /etc/init.d/mysqld start

9. Log in to MySQL

# /usr/local/mysql/bin/mysql -uroot -p system-generated password

10. Change the root password

mysql>set password = password('new password');
mysql>flush privileges;
mysql>exit

11. Log out and log in again

# /usr/local/mysql/bin/mysql -uroot -p'new password'

The above is a detailed tutorial on how to compile and install MySQL 5.7.18 from source code on CentOS 6.6. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • A simple way to change the password of mysql just installed in Linux
  • Solution to MySql Error 1698 (28000)
  • Solution to the problem that the number of MySQL connections is limited to 214 in CentOS 7
  • Analyzing the troublesome Aborted warning in MySQL through case studies
  • Solve the problem that IN subquery in MySQL will cause the index to be unusable
  • Detailed example of MySQL exchange partition

<<:  Add and delete table information using javascript

>>:  How to add a disk in Vmware: Expand the disk

Recommend

How to implement checkbox & radio alignment

Not only do different browsers behave differently...

Detailed explanation of identifying files with the same content on Linux

Preface Sometimes file copies amount to a huge wa...

How to calculate the value of ken_len in MySQL query plan

The meaning of key_len In MySQL, you can use expl...

A brief discussion on the characteristics of CSS float

This article introduces the characteristics of CS...

View MySQL installation information under Linux server

View the installation information of mysql: #ps -...

How to customize at and cron scheduled tasks in Linux

There are two types of scheduled tasks in Linux s...

Summarize the common application problems of XHTML code

Over a period of time, I found that many people d...

How to remove the dotted border when clicking a link in FireFox

I encountered several browser compatibility issue...

Negative distance (empathy) - iterative process of mutual influence

Negative distance refers to empathy. Preface (rai...

Detailed explanation of JavaScript Proxy object

Table of contents 1. What is Proxy? 2. How to use...

Vue3 manual encapsulation pop-up box component message method

This article shares the specific code of Vue3 man...

MySQL 8.0.22 download, installation and configuration method graphic tutorial

Download and install MySQL 8.0.22 for your refere...

Tutorial on processing static resources in Tomcat

Preface All requests in Tomcat are handled by Ser...

Goodbye Docker: How to Transform to Containerd in 5 Minutes

Docker is a very popular container technology. Th...

A brief analysis of mysql index

A database index is a data structure whose purpos...