centos7编译安装mysql5.6
时间: 2023-10-23 20:15:26 浏览: 136
CentOS 7.2 Yum编译安装MySQL 5.6
好的,以下是 centos7 编译安装 mysql5.6 的步骤:
1. 安装依赖库
```
yum -y install gcc gcc-c++ ncurses-devel cmake
```
2. 下载 mysql5.6 源码包
```
wget https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.51.tar.gz
```
3. 解压源码包
```
tar -zxvf mysql-5.6.51.tar.gz
```
4. 进入解压后的目录,创建编译目录
```
cd mysql-5.6.51
mkdir build
cd build
```
5. 编译安装
```
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci
make && make install
```
6. 初始化数据库
```
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
```
7. 启动 mysql
```
./bin/mysqld_safe --user=mysql &
```
8. 设置 root 密码
```
./bin/mysqladmin -u root password 'yourpassword'
```
9. 登录 mysql
```
./bin/mysql -u root -p
```
以上就是 centos7 编译安装 mysql5.6 的步骤,希望对你有帮助。
阅读全文