1)下载安装包, 5.7版本需要下载一个Boost C++ 1.59.0,(下载比较慢)
#cd /data/soft
# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21.tar.gz
# tar -xfzf mysql-5.7.21.tar.gz
# wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
# tar -xfzf boost_1_59_0.tar.gz
2)安装依赖包:
#yum -y install gcc gcc-c++ ncurses ncurses-devel bison libgcrypt perl make cmake
3)建立用户,授权安装目录和数据目录权限,这步可以放到编译完做
# useradd -g mysql mysql -s /sbin/nologin
4)编译安装
# cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_DATADIR=/usr/lcoal/mysql/data -DSYSCONFDIR=/etc/my.cnf -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DENABLE_DEBUG_SYNC=0 -DENABLED_LOCAL_INFILE=1 -DENABLED_PROFILING=1 -DMYSQL_TCP_PORT=3306 -DWITH_DEBUG=0 -DWITH_SSL=yes -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/data/soft/boost_1_59_0
# make && make install
#创建mysql用户(但是不能使用mysql账号登陆系统)
# useradd -g mysql mysql -s /sbin/nologin
# chown -R mysql:mysql /usr/local/mysql
#进入安装路径,执行初始化配置脚本,创建系统自带的数据库和表
# cd /usr/local/mysql/bin/
#mysqld --defaults-file=/etc/my.cnf --initialize --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
#添加服务,拷贝服务脚本到init.d目录,并设置开机启动
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
# chkconfig --add mysql
# chkconfig mysql on
#service mysql start
5)开启远程连接
#系统提示输入数据库root用户的密码,输入完成后即进入mysql控制台
#mysql -uroot -p
#use mysql;
#GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
#FLUSH PRIVILEGES;
参考博客:
https://www.cnblogs.com/yangchunlong/p/8477743.html
https://www.cnblogs.com/oracleloyal/p/6060779.html
https://blog.csdn.net/wayne_primes/article/details/79565883
https://blog.51cto.com/mofansheng/2110911
https://blog.csdn.net/sun614345456/article/details/53672150
转载于:https://blog.51cto.com/6290105/2136379