Source package compiled and installed mysql5.7

Quguan network, then download speed is very slow, anyway, I have been dozens of K, I asked a friend to go to 500K, if over the wall, then it may be faster

Mirroring below with Tsinghua

First clean installation environment it may have built-in mariadb

yum erase mariadb mariadb-server mariadb-libs mariadb-devel -y

1. Download and unzip

wget https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7/mysql-boost-5.7.25.tar.gz
tar zxvf mysql-boost-5.7.25.tar.gz
cd mysql-5.7.25/ && ls

This package is built the boost library, if this is not the case, then it also needs a boost under a separate library package, unpacked unpacked into mysql directory on the line. boost library download

2. Create mysql account (no home directory, the user is not logged in the shell)

useradd -r mysql -M -s /sbin/nologin

3. Install the compilation tools, if you already have a negligible

yum -y install ncurses ncurses-devel openssl-devel bison gcc gcc-c++ make cmake

4. Create mysql installation directory and change its owner to mysql

mkdir -p /usr/local/mysql/data&&chown -R mysql:mysql /usr/local/mysql

5. Use cmake generate compilation environment in the package directory codecs

cmake . -DWITH_BOOST=boost/ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DMYSQL_DATADIR=/usr/local/mysql/data -DINSTALL_MANDIR=/usr/share/man -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DEXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1

This prompt is generated to complete.

-DCMAKE_INSTALL_PREFIX = / usr / local / mysql \ MySQL installation directory

-DSYSCONFDIR = / etc \ configuration file storage location (default configuration files may not be mounted)

-DMYSQL_DATADIR = / usr / local / mysql / data \ directory to store location data, and error log files in this directory will be

-DINSTALL_MANDIR = / usr / share / man \ Documents Help

-DMYSQL_TCP_PORT = 3306 \ default port

-DMYSQL_UNIX_ADDR = / tmp / mysql.sock \ sock file location, used for network communications, client server when the connection will be used

-DDEFAULT_CHARSET = utf8 \ default character set. Supported character set, can be adjusted

-DEXTRA_CHARSETS = all \ extended character set supports all

-DDEFAULT_COLLATION = utf8_general_ci \ support utf8 character sets

-DWITH_READLINE = 1 \ turned down the command history

-DWITH_SSL = system \ login using the private key and certificate (public key) can be encrypted. Application and long connection. Disadvantages: Slow

-DWITH_EMBEDDED_SERVER = 1 \ embedded database

-DENABLED_LOCAL_INFILE = 1 \ pour data from a local, not a backup and recovery.

6. Compile and install

make&&make install

Then there is a long waiting time ~~

after finishing

7. initialization

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

Then get the initial password

8. Configuration my.cnf

vim /etc/my.cnf

[mysqld]

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

server-id = 1

log-bin=mysql-bin

Installation directory and data directory is necessary to store, and if you do not specify port 3306 by default, I installed a personal habit to open binlog log, there is a demand to increase it according to their individual needs configuration.

9. Start mysql

# cp support-files/mysql.server /etc/init.d/mysqld       // 生成mysql.server脚本

# chkconfig --add mysqld                                 // 给MySQL设置启动项

# service mysqld start                                   // 执行启动命令

# chkconfig mysqld on                                    // 开机启动

10. Change Password

./bin/mysql -uroot -p

Enter the previously obtained initial password to access the database.

mysql> set password=password('123');

11. Add the environment variable

vi ~/.bash_profile

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

source ~/.bash_profile

Look at the next restart mysql there is no boot from Kai, complete.

Published 60 original articles · won praise 9 · views 30000 +

Guess you like

Origin blog.csdn.net/qq_44697035/article/details/100553570