警告
本文最后更新于 2020-06-01 09:31,文中内容可能已过时。
安装包下载地址:https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-5.7.20.tar.gz
依赖包:
1
| yum -y install make gcc-c++ cmake bison-devel ncurses-devel libtool bison perl perl-devel perl perl-devel
|
1. 解压
1
| tar -zxvf mysql-boost-5.7.20.tar.gz
|
2. 创建用户
1
| useradd mysql -M -s /sbin/nologin
|
3. 编译安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| cd mysql-5.7.20/
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITH_BOOST=boost \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
-DWITH_EMBEDDED_SERVER=1
make && make install
|
4. 初始化数据库
1
2
3
4
| mkdir -p /data/mysql
chown -R mysql.mysql /data/mysql
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
|
5. 编辑配置文件
1
2
3
4
5
6
7
8
9
| vim /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
port=3306
[mysql]
socket=/tmp/mysql.sock
|
6. 创建启动脚本,启动服务
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| vim /etc/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
#启动和设置开机自启
systemctl start mysqld
systemctl enable mysqld
|
##7. 添加环境变量,在文件末尾添加
1
2
3
4
5
| vim /etc/profile
export PATH=/usr/local/mysql/bin:$PATH
#执行profile,重新生效
source /etc/profile
|
##8.设置mysql密码
1
| mysqladmin -S /tmp/mysql.sock -uroot password 'mima'
|