MySQL5.7.13源码编译安装指南

时间:2024-01-21 15:12:03

系统 CenterOs 6.5

1.安装依赖包(cmake make gcc等,其实好多都有了,不需要更新,为了防止世界被破坏,就装下)

yum install gcc gcc-c++ -y
yum install -y ncurses-devel.x86_64
yum install -y cmake.x86_64
yum install -y libaio.x86_64
yum install -y bison.x86_64
yum install -y gcc-c++.x86_64

2.安装boost库1.59(听高手们说,只能是这个版本,没试过其他的,懒是楼主的本性,于是菜鸟们跟着命令走吧)

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

3.添加用户组和用户mysql(又是参考了各种大神的命令)

groupadd mysql
useradd -g mysql mysql

4.下载安装mysql5.7.13(下载时可能需要*?一直开着代理的楼主不知道是否需要*。。。接着就是需要root权限,当然这是确定的)

wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.13.tar.gz

tar zxvf mysql-5.7..tar.gz
cd mysql-5.7.
cmake -DCMAKE_INSTALL_PREFIX=/home/mysql -DMYSQL_DATADIR=/home/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT= -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE= -DWITH_INNOBASE_STORAGE_ENGINE= -DWITH_ARCHIVE_STORAGE_ENGINE= -DWITH_BLACKHOLE_STORAGE_ENGINE= -DWITH_MEMORY_STORAGE_ENGINE= -DDOWNLOAD_BOOST= -DWITH_BOOST=/usr/local/boost make && make install

5.初始化数据库(就是数据库的配置,呵呵,太给力的程序,大家要记住神一样的密码,楼主输错了无数次,终于成功)

/home/mysql/bin/mysqld --initialize --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data
#返回信息最后一行 2016--21T07::.962094Z  [Note] A temporary password is generated for root@localhost: KQqCK:lmC15u #密码要保存

6.调整配置文件(各种复制黏贴)

mv /etc/my.cnf /etc/my.cnf.bak
cp /home/mysql/support-files/my-default.cnf /etc/my.cnf

7.启动mySQl实例

/home/mysql/bin/mysqld_safe

8.另外开一个控制台,登陆mysql,然后输入那令人蛋疼的密码

cd /home/mysql/bin
./mysql -uroot -p'KQqCK:lmC15u'

9.修改密码 alter user 'root'@'localhost' identified by '123456';

#提示信息
#Enter password:
#Welcome to the MySQL monitor. Commands end with ; or \g.
#Your MySQL connection id is 3
#Server version: 5.7.13 #Copyright (c) 2000, 2016, 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> alter user 'root'@'localhost' identified by '123456';

10.至此, mysql 5.7.13编译安装成功.