centos7源代码编译安装mysql5.6.50
时间: 2023-11-01 07:55:44 浏览: 139
以下是在 CentOS 7 上编译安装 MySQL 5.6.50 的步骤:
1. 确保系统已安装必要的依赖库:
```shell
yum -y install gcc gcc-c++ make cmake bison-devel ncurses-devel
```
2. 下载 MySQL 5.6.50 源码包:
```shell
wget https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.50.tar.gz
```
3. 解压缩源码包:
```shell
tar -zxvf mysql-5.6.50.tar.gz
cd mysql-5.6.50
```
4. 配置编译选项:
```shell
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_LIBWRAP=0 \
-DWITH_EMBEDDED_SERVER=0 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BOOST=../boost
```
5. 编译安装:
```shell
make && make install
```
6. 添加 MySQL 用户和用户组:
```shell
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
```
7. 初始化 MySQL 数据库:
```shell
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/
```
8. 修改配置文件:
```shell
cp support-files/my-default.cnf /etc/my.cnf
vi /etc/my.cnf
```
在 [mysqld] 段中添加以下内容:
```shell
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
```
9. 启动 MySQL 服务:
```shell
/usr/local/mysql/support-files/mysql.server start
```
10. 设置开机自启动:
```shell
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig mysql on
```
11. 设置 MySQL 环境变量:
```shell
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
source /etc/profile
```
现在,你已经成功地在 CentOS 7 上编译安装了 MySQL 5.6.50。
阅读全文