Get the App
SLTechnology News&Howtos  ›  Database  › 

Mysql5.7 source code installation database deployment

Shulou Source: shulou.com Published: 2022-06-01 10:34:45 10月30日 Update

** mysql 5.7.20 source code deployment

by mj bacon **

1)Install the base package

yum install -y gcc gcc-c++ automake autoconf git make

yum -y install cmake bison-devel ncurses-devel libaio-devel

2)Create directory (for download files)

mkdir -p /home/mjboy/tools

Download mysql5.7.20 here/home/mjboy/tools directory

wget https://downloads.mysql.com/archives/get/file/mysql-5.7.20.tar.gz

wget https://downloads.mysql.com/archives/get/file/mysql-boost-5.7.20.tar.gz

3)Create mysql user:

groupadd -g 800 mysql

useradd -u 800 mysql -s /sbin/nologin -M -g mysql

4) Unpack tar package

tar xf mysql-5.7.20.tar.gz

tar xf mysql-boost-5.7.20.tar.gz

5)cmake configure compilation options

cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.7.20 \

-DMYSQL_DATADIR=/application/mysql-5.7.20/data \

-DMYSQL_UNIX_ADDR=/application/mysql-5.7.20/tmp/mysql.sock \

-DDOWNLOAD_BOOST=1 \

-DWITH_BOOST=/home/mjboy/tools/mysql-5.7.20/boost \

-DSYSCONFDIR=/etc \

-DDEFAULT_CHARSET=utf8mb4 \

-DDEFAULT_COLLATION=utf8mb4_general_ci \

-DWITH_EXTRA_CHARSETS=all \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_FEDERATED_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_ZLIB=bundled \

-DWITH_SSL=bundled \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_EMBEDDED_SERVER=1 \

-DENABLE_DOWNLOADS=1 \

-DWITH_DEBUG=0

Note: utf8mb4 is a superset of utf8, but generally utf8 is sufficient, and utf8mb4 consumes more space.

Parameter specific meaning:

Refer to official documentation--cmake mysql5.7 Reference

https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html

6)Compile & Install

make && make install

7)Set mysql soft links

ln -s /application/mysql-5.7.20/ /application/mysql

Thinking: Why set up soft links--(version change, provide convenience)

8)Copy startup files and configuration files (if not, create your own, preferably make my.cnf)

Set mysqld startup script

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

#configure my.cnf

cp /application/mysql-5.7.20/support-files/my-default.cnf /etc/my.cnf

[root@mysql57 ~]# cat /etc/my.cnf

[client]

port = 3306

socket = /application/mysql/data/tmp/mysql.sock

#This configuration segment sets the conditions for starting the MySQL service; in this case, no-auto-rehash ensures that the service starts faster.

#no-auto-rehash

[server]

user = root

port = 3306

socket = /application/mysql/data/tmp/mysql.sock

basedir = /application/mysql

datadir = /application/mysql/data/

9)set the environment variable

[root@master data]# echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile

[root@master data]# tail -1 /etc/profile

[root@master data]# export PATH=/application/mysql/bin:$PATH

[root@master data]# source /etc/profile

[root@master data]# echo $PATH

/application/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

Note: Why put application environment variables first?

http://oldboy.blog.51cto.com/2561410/1122867 (sequential effects of environmental variables)

10)authorized

chown -R mysql:mysql /application/mysql/data/

chmod -R 1777 /tmp/

11)initialization

/application/mysql-5.7.20/bin/mysqld --initialize --user=mysql --basedir=/application/mysql-5.7.20/ --datadir=/application/mysql-5.7.20/data

#Initial password recorded

#A temporary password is generated for root@localhost: NphU.; 4Xdl#w

12)Create mysql.sock storage directory and authorize

mkdir /application/mysql-5.7.20/tmp

chown -R mysql.mysql /application/mysql-5.7.20/

13)start

The requested URL/etc/init.d/was not found on this server.

14)Change initial password

mysqladmin -uroot -p'NphU.; 4Xdl#w' password 'root'

15)Login to mysql successfully!

[root@mysql57 ~]# mysql -uroot -proot -e "select version();show databases;"

mysql: [Warning] Using a password on the command line interface can be insecure.

+-----------+

| version() |

+-----------+

| 5.7.20 |

+-----------+

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| sys |

| tmp |

+--------------------+

[root@mysql57 ~]#

Tags: Configuration variables files environment directories passwords links references services compilation source code success location author sequence parameters meaning bacon foundation enough Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Technology Xiaomi vpn OPPO Reno