1.安装环境:软件包:mysql-5.6.31.tar.gz
需求相关选项:
安装基目录basedir:/mydb/mysql31
数据存放目录datadir:/mydb/mysql31/data端口号:3308socket文件存放目录:$basedir/mysql31.sock根据需求开启相应功能
安装步骤:
下载软件包并解压到临时目录
[root@xzw mysql]# pwd
/soft/mysql[root@xzw mysql]# tar -xf mysql-5.6.31.tar.gz -C mysql31
根据需求进行配置(此处需要根据个人需求来配置,这里以下为例):
[root@xzw mysql-5.6.31]# cat cmake.sh
cmake . \-DCMAKE_INSTALL_PREFIX=/mydb/mysql31 \-DMYSQL_DATADIR=/mydb/mysql31/data \-DSYSCONFDIR=/etc \-DMYSQL_TCP_PORT=3308 \-DMYSQL_UNIX_ADDR=/mydb/mysql31/mysql31.sock \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_PARTITION_STORAGE_ENGINE=1 \-DWITH_FEDERATED_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DENABLED_LOCAL_INFILE=1 \-DEXTRA_CHARSETS=all \-DDEFAULT_CHARSET=utf8mb4 \-DDEFAULT_COLLATION=utf8mb4_general_ci
编译&安装
make && make install
后续配置
初始化数据库
注意:进入到安装目录里/mydb/mysql31
1. 修改目录权限[root@misshou mysql31]# chown mysql. -R /mydb/mysql31/2. 初始化数据库[root@misshou mysql31]# scripts/mysql_install_db --user=mysql3. 查看数据目录里是否有数据文件[root@misshou mysql31]# ls data/ibdata1 ib_logfile0 ib_logfile1 mysql performance_schema test
拷贝启动脚本到/etc/init.d/目录
[root@xzw mysql31]# cp support-files/mysql.server /etc/init.d/mysql31
启动数据库
[root@xzw mysql31]# service mysql31 start
安全配置
[root@xzw mysql31]# bin/mysql_secure_installation --user=mysql