在CentOS7.4上手动编译安装Mysql-5.7.20
实验环境:
CentOS 7.4
mysql软件: mysql-boost-5.7.20.tar.gz
1.安装编译工具
yum -y install \
ncurses \
ncurses-devel \
bison \
cmake\
gcc \
gcc-c++ \
make
2.解压包
tar xf mysql-boost-5.7.20.tar.gz
3.定制配置
cd mysql-5.7.20/
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/etc \
-DSYSTEMD_PID_DIR=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=boost \ //5.7版本必须添加这个参数
-DWITH_SYSTEMD=1
4.编译并安装
make && make install
5.添加程序帐户,并相关设置
useradd -s /sbin/nologin mysql
chown -R mysql:mysql /usr/local/mysql/
chown mysql:mysql /etc/my.cnf
6.修改配置文件
vi /etc/my.cnf
[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysql]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
7.设置环境变量
echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile //把这两个路径添加到环境变量中,并放到profile文件中使之开机自运行,否则不生效
echo 'export PATH' >> /etc/profile //把PATH设为全局变量
source /etc/profile
8.初始化数据库
cd /usr/local/mysql/
bin/mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
9.添加到systemctl系统服务
cp usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
systemctl daemon-reload
systemctl start mysqld
netstat -anpt | grep 3306
systemctl enable mysqld
10.Mysql设置帐户和密码,默认无密码
mysqladmin -u root -p password "abc123"
mysql -u root -p
上一篇: footer.html中中文乱码的解决
下一篇: 动态SQL编写教程
推荐阅读
-
在Mac上编译安装PHP7的开发环境
-
在CentOS7.4上手动编译安装Mysql-5.7.20
-
在Mac OS上安装Go语言编译器的方法
-
其他笔记 - Mono for Windows 跨平台 Runtime 在Win10上编译和安装
-
在CentOS/Debian/Ubuntu上编译安装最新版gnu make 和GNU 'binutils' (as and ld)
-
在win10的vs2019上安装并编译libevent库
-
在vmware上安装gentoo-下(编译内核)
-
在vmware上安装gentoo-下(编译内核)
-
在麒麟V10服务器上编译安装Storm的详细过程
-
在CentOS上以源码编译的方式安装Greenplum数据库