01: mysql 5.6.34 编译安装 (centos7)
1:下载mysql5.6
[root@mysql180 ~]# wget https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.6/mysql-5.6.43.tar.gz
2:安装依赖
[root@mysql180 tools]# yum install -y ncurses-devel libaio-devel gcc gcc-c++ bison
3:安装cmake
[root@mysql180 tools]# yum install -y cmake
4:创建用户
[root@mysql180 tools]# useradd mysql -s /sbin/nologin -M
5:修改hosts
[root@mysql181 ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.6.181 mysql181
6:解压, cd mysql-5.6.43/
[root@mysql180 tools]# tar xf mysql-5.6.43.tar.gz
[root@mysql181 tools]# cd mysql-5.6.43/
7:创建程序文件夹
[root@mysql181 mysql-5.6.43]# mkdir /application
8:编译
[root@mysql181 mysql-5.6.43]#
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.43 \
-DMYSQL_DATADIR=/application/mysql-5.6.43/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.6.43/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_ZLIB=bundled \
-DWITH_SSL=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_DEBUG=0
9:编译make && 安装make install
[root@mysql181 mysql-5.6.43]# make && make install
10:做软连接
[root@mysql181 application]# ln -s /application/mysql-5.6.43/ /application/mysql
11: 复制配置文件
[root@mysql181 mysql-5.6.43]# cp support-files/my-default.cnf /etc/my.cnf
12:服务启动脚本,并授权
[root@mysql181 mysql-5.6.43]# cp support-files/mysql.server /etc/init.d/mysqld
[root@mysql181 scripts]# chmod 700 /etc/init.d/mysqld
[root@mysql181 mysql-5.6.43]# chmod u+x /etc/init.d/mysqld
13:创建 tmp目录,整个文件夹授权
[root@mysql181 scripts]# mkdir /application/mysql-5.6.43/tmp
[root@mysql181 scripts]# chown -R mysql.mysql /application/mysql/
14:进入初始化命令的脚本,初始化数据库
[root@mysql181 scripts]# cd /application/mysql/scripts/
[root@mysql181 scripts]# ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data --user=mysql
15:导入环境变量:
[root@mysql181 scripts]# echo 'PATH=/application/mysql/bin/:$PATH' >>/etc/profile
[root@mysql181 scripts]# source /etc/profile
16: 启动,加入开机自启
[root@mysql181 mysql]# /etc/init.d/mysqld start
[root@mysql181 scripts]# chkconfig mysqld on
17:更改mysql root初始密码:
[root@mysql181 mysql]# mysqladmin -uroot password '123456'
18:登录mysql:
[root@mysql181 mysql]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.43 Source distribution
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
到此mysql 5.6 编译安装成功!
------------------ ---------------------------------------------------------------------------------------------------------------
运维