=================================================================
准备工作
1.源码包
2.大一点的磁盘(不然中间会失败)
3.较大的内存(因为需要编译)
=================================================================
1、准备逻辑卷
[root@node02 ~]# df -hT | grep "data"
/dev/mapper/vg1-lv1 xfs 4.0G 33M 4.0G 1% /mydata/data
=================================================================
2、卸载系统自带的mariadb软件
[root@mysqltest ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.44-2.el7.centos.x86_64
[root@mysqltest ~]# rpm -e --nodeps mariadb-libs
=================================================================
3、修改数据目录的所属
[root@node02 ~]# useradd -s /sbin/nologin -M mysql
[root@node02 ~]# chown -R mysql.mysql /mydata/data/
=================================================================
4、安装cmake编译器
[root@node02 ~]# yum install -y cmake
=================================================================
5、解压mysql
[root@node02 ~]# tar zxf mysql-boost-5.7.17.tar.gz
=================================================================
6、错误预防
[root@node02 ~]# yum groupinstall -y "Development Tools" "Server Platform Development" "Desktop Platform Development"
[root@node02 ~]# yum install -y ncurses-devel.x86_64
=================================================================
7、编译安装mysql
[root@node02 ~]# cd mysql-5.7.17/
[root@node02 mysql-5.7.17]# cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_DATADIR=/mydata/data \
-DMYSQL_TCP_PORT=3306 \
-DWITH_BOOST=boost/boost_1_59_0/ \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
[root@mysqltest mysql-5.7.17]# make
[root@mysqltest mysql-5.7.17]# make install
[root@mysqltest ~]# chown -R root.mysql /usr/local/mysql/
=================================================================
8、初始化数据库
[root@mysql57 ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/mydata/data
=================================================================
9、复制mysql配置文件
[root@node02 ~]# cd /usr/local/mysql/support-files/
[root@node02 support-files]# cp my-default.cnf /etc/my.cnf
[root@node02 support-files]# vim /etc/my.cnf
[mysqld]
...
basedir=/usr/local/mysql
datadir=/mydata/data
port=3306
server_id=121
socket=/tmp/mysql.sock
=================================================================
10、启动mysql服务
[root@mysqltest data]# /usr/local/mysql/bin/mysqld_safe --user=mysql &
[root@mysqltest data]# ss -antp | grep mysqld
=================================================================
11、修改环境变量PATH
[root@mysqltest data]# cat /etc/profile.d/mysql.sh
export PATH=$PATH:/usr/local/mysql/bin
[root@mysqltest data]# source /etc/profile.d/mysql.sh
[root@mysqltest data]# mysql -u root -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Www.1.com';
mysql> FLUSH PRIVILEGES;
=================================================================
11、设置mysql开机自动启动
# vim /etc/rc.d/rc.local
/usr/local/mysql/bin/mysqld_safe --user=mysql &