mysql 5.6. 8 source code installation process

  • 2021-10-11 19:52:03
  • OfStack

Kernel:


[root@opop ~]# cat /etc/centos-release 
CentOS release 6.8 (Final)
[root@opop ~]# uname -a
Linux opop 2.6.32-642.el6.x86_64 #1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Start installation:


[root@opop ~]# for i in `rpm -qa | grep mysql`;do yum remove $i;done   // Delete your own mysql
[root@opop ~]# yum -y install wget gcc gcc-c++ ncurses-devel cmake make perl bison git

To create an mysql user group:


[root@opop ~]# groupadd mysql 
[root@opop ~]# useradd -r -g mysql mysql

Create mysql installation directory and database file storage directory:


[root@opop ~]# mkdir -p /usr/local/mysql
[root@opop ~]# mkdir -p /usr/local/mysql/data

Modify directory owners and groups:


[root@opop ~]# chown -R mysql:mysql /usr/local/mysql/data 
[root@opop ~]# chown -R mysql:mysql /usr/local/mysql

Unpack:


[root@opop ~]# tar -zxvf mysql-5.6.38.tar.gz
[root@opop ~]# cd mysql-5.6.38

Compile:


[root@opop mysql-5.6.38 ]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/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=/usr/local/mysql/data \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_USER=mysql \
-DENABLE_DOWNLOADS=1
[root@opop mysql-5.6.38 ]# make && make install
// Note: It takes a long time to compile and needs to wait patiently 
// View the following results: 
//[root@opop mysql-5.6.38 ]# ll /usr/local/mysql/

Clear temporary files:


[root@opop mysql-5.6.38 ]# make clean

Initialize mysql:


[root@opop ~]# cd /usr/local/mysql/
[root@opop mysql]# scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data 
[root@opop mysql ]# chown -R mysql:mysql /usr/local/mysql 
[root@opop mysql ]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
[root@opop mysql ]# /etc/init.d/mysql start
[root@opop mysql ]# ps -aux |grep mysql

Configure environment variables:


[root@opop mysql]# vim /etc/profile

Add at the end


[root@opop ~]# for i in `rpm -qa | grep mysql`;do yum remove $i;done   // Delete your own mysql
[root@opop ~]# yum -y install wget gcc gcc-c++ ncurses-devel cmake make perl bison git
0

Reload profile (effective immediately)


[root@opop ~]# for i in `rpm -qa | grep mysql`;do yum remove $i;done   // Delete your own mysql
[root@opop ~]# yum -y install wget gcc gcc-c++ ncurses-devel cmake make perl bison git
1

Restart the mysql service:


[root@opop ~]# for i in `rpm -qa | grep mysql`;do yum remove $i;done   // Delete your own mysql
[root@opop ~]# yum -y install wget gcc gcc-c++ ncurses-devel cmake make perl bison git
2

First landing:


[root@opop mysql]# mysql -u root mysql

Authorization:


[root@opop ~]# for i in `rpm -qa | grep mysql`;do yum remove $i;done   // Delete your own mysql
[root@opop ~]# yum -y install wget gcc gcc-c++ ncurses-devel cmake make perl bison git
4

Set the database password:


[root@opop ~]# for i in `rpm -qa | grep mysql`;do yum remove $i;done   // Delete your own mysql
[root@opop ~]# yum -y install wget gcc gcc-c++ ncurses-devel cmake make perl bison git
5

Refresh:


[root@opop ~]# for i in `rpm -qa | grep mysql`;do yum remove $i;done   // Delete your own mysql
[root@opop ~]# yum -y install wget gcc gcc-c++ ncurses-devel cmake make perl bison git
6

Exit:


[root@opop ~]# for i in `rpm -qa | grep mysql`;do yum remove $i;done   // Delete your own mysql
[root@opop ~]# yum -y install wget gcc gcc-c++ ncurses-devel cmake make perl bison git
7

Log in again after changing the password:


[root@opop mysql]# mysql -u root -p 
Enter password:               // Enter here 6 A 1 You can come in 

Set up the boot automatic startup service:


[root@opop ~]# for i in `rpm -qa | grep mysql`;do yum remove $i;done   // Delete your own mysql
[root@opop ~]# yum -y install wget gcc gcc-c++ ncurses-devel cmake make perl bison git
9

Summarize


Related articles: