Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql5.7 source code installation database deployment

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

** 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 ~]#

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report