编译安装MySQL-5.7
时间: 2023-10-01 11:02:12 浏览: 184
mysql5.7安装
以下是在Linux系统上编译安装MySQL-5.7的步骤:
1.下载MySQL-5.7源码包:
```
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.34.tar.gz
```
2.解压缩源码包:
```
tar -zxvf mysql-5.7.34.tar.gz
```
3.安装依赖库:
```
sudo apt-get install cmake libncurses5-dev libncursesw5-dev bison
```
4.创建MySQL安装目录:
```
sudo mkdir /usr/local/mysql
sudo chown -R `whoami` /usr/local/mysql
```
5.编译MySQL源码:
```
cd mysql-5.7.34
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 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_BOOST=/usr/local/boost_1_59_0
```
6.编译完成后,使用make命令进行编译:
```
make
```
7.编译完成后,使用make install命令进行安装:
```
sudo make install
```
8.设置MySQL配置文件:
```
sudo cp support-files/my-default.cnf /etc/my.cnf
```
9.创建MySQL数据目录:
```
sudo mkdir /usr/local/mysql/data
```
10.初始化MySQL:
```
sudo /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
```
11.启动MySQL服务:
```
sudo /usr/local/mysql/support-files/mysql.server start
```
12.设置MySQL自启动:
```
sudo cp support-files/mysql.server /etc/init.d/mysql
sudo chmod +x /etc/init.d/mysql
sudo update-rc.d mysql defaults
```
以上就是在Linux系统上编译安装MySQL-5.7的步骤。
阅读全文