1、下载并上传 MySQL-5.7.14.tar.gz
http://dev.mysql.com/downloads/file/?id=466288
1 |
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.16.tar.gz |
2、解压源码包
1 |
tar -zxf msql-5.7.14.tar.gz |
3、安装依赖包
1 |
yum -y install gcc-c++ ncurses-devel cmake make perl gcc autoconf automake zlib libxml libgcrypt libtool bison |
4、下载Boost库(对应版本高于或低于这个版本都有问题)
1 2 3 4 |
wget http://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz tar zxvf boost_1_59_0.tar.gz mv boost_1_59_0 /usr/local/boost |
5、添加mysql用户
1 2 |
groupadd mysql useradd -r -g mysql -s /bin/false mysql |
6、预编译
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/server/mysql \ -DMYSQL_DATADIR=/home/mysql/data \ -DSYSCONFDIR=/usr/local/server/mysql/etc \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DMYSQL_TCP_PORT=3306 \ -DMYSQL_USER=mysql \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/usr/local/boost |
7、编译安装
1 2 |
make make install |
8、修改 /usr/local/server/mysql/etc/my.cnf
1 2 3 4 5 6 7 |
[mysqld] datadir=/home/mysql/data socket=/home/mysql/data/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 character_set_server=utf8 |
9、修改权限
1 |
chown -R mysql:mysql /usr/local/server/mysql/ |
10、建立数据库目录
1 2 |
mkdir -p /home/mysql/data chown mysql:mysql /home/mysql/data |
11、数据库初始化
1 |
/usr/local/server/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/server/mysql --datadir=/home/mysql/data |
12、设置加密连接
1 |
/usr/local/server/mysql/bin/mysql_ssl_rsa_setup |
13、加入系统服务
1 2 3 4 |
cp support-files/mysql.server /etc/init.d/mysqld 修改 mysqld 文件里的 basedir datadir 属性 chkconfig mysqld on # 设置开机自启动 chkconfig --list | grep mysqld |
14、服务启动 重启 停止
1 2 3 |
service mysqld start service mysqld restart service mysqld stop |
15、登录并修改初始密码
1 |
SET PASSWORD FOR 'root'@'localhost'=PASSWORD('newpassword'); |
16、访问数据库
1 |
mysql -uroot -p |