编译安装mysql8.0
时间: 2023-11-22 11:49:06 浏览: 270
以下是在Red Hat Enterprise Linux Server release 7.6上源码编译安装MySQL 8.0.X的步骤:
1. 下载MySQL源码包并解压缩:
```shell
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.18.tar.gz
tar -zxvf mysql-8.0.18.tar.gz
```
2. 安装编译MySQL所需的依赖包:
```shell
yum install -y cmake gcc gcc-c++ ncurses-devel openssl-devel bison
```
3. 进入MySQL源码目录,创建一个用于编译的目录:
```shell
cd mysql-8.0.18
mkdir build
cd build
```
4. 运行cmake命令生成Makefile文件:
```shell
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_TCP_PORT=3306 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_LIBEDIT=1 \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci
```
5. 运行make命令进行编译:
```shell
make
```
6. 运行make install命令进行安装:
```shell
make install
```
7. 配置MySQL环境变量:
```shell
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
source /etc/profile
```
8. 初始化MySQL:
```shell
cd /usr/local/mysql
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
```
9. 启动MySQL服务:
```shell
bin/mysqld_safe --user=mysql &
```
10. 修改MySQL的root用户密码:
```shell
bin/mysqladmin -u root password 'new-password'
```
以上是在Red Hat Enterprise Linux Server release 7.6上源码编译安装MySQL 8.0.X的步骤。如果您遇到了问题,可以参考MySQL官方文档或者在MySQL社区寻求帮助。
阅读全文