mysql5.7编译安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql5.7编译安装相关的知识,希望对你有一定的参考价值。
mysql5.7编译安装
mkdri /home/data
cd /home/data
rz 软件包(yum install lrzsz)
mysql-boost-5.7.15.tar.gz
mysql-5.7.15.tar.gz
cmake-3.5.2.tar.gz
预装软件:
yum install -y make gcc gcc-c++
yum install -y ncurses-devel
yum intsall -y bison bison-devel
yum install -y openssl openssl-devel
安装cmake
wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz
# tar xf cmake-3.5.2.tar.gz
# cd cmake-3.5.2
# ./bootstrap
# gmake
# gmake install
Boost库放到预装位置
wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
# tar xzvf boost_1_59_0.tar.gz(别的版本报错,也可以mysql官网下载mysql-boost-5.7.15.tar.gz 包)
编译安装mysql
mkdir -p /usr/local/mysql
mkdir -p /home/data/mysqldb
useradd mysql
cd /home/data
chown -R mysql:mysql mysqldb
tar -xzvf mysql-5.7.15.tar.gz
tar -xzvf mysql-boost-5.7.15.tar.gz
cd mysql-5.7.15
如果想清理此前的编译所生成的文件,则需要使用如下命令:
make clean
rm CMakeCache.txt
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/home/data/mysqldb \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_LIBWRAP=0 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_BOOST=/home/data/mysql-5.7.15/boost \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make
make install
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/home/data/mysqldb
“–initialize”会生成一个随机密码(~/.mysql_secret),而”–initialize-insecure”不会生成密码
–datadir目标目录下不能有数据文件
mysql的服务脚本
#拷贝脚本
cp support-files/mysql.server /etc/init.d/mysqld
#赋予权限
chmod +x /etc/init.d/mysqld
#增加至sysV服务
chkconfig --add mysqld
#开机自启动
chkconfig mysqld on
修改/usr/local/mysql权限
chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
启动数据库
service mysqld start
添加环境变量
修改 /etc/profile
末尾追加:export PATH=$PATH:/usr/local/mongodb/bin:/usr/local/mysql/bin
echo ‘export PATH=$PATH:/usr/local/mongodb/bin:/usr/local/mysql/bin‘ >>/etc/profile
source /etc/profile
dbrootpwd=oneinstack #数据库root密码
/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to [email protected]‘127.0.0.1‘ identified by \"$dbrootpwd\" with grant option;"
/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to [email protected]‘localhost‘ identified by \"$dbrootpwd\" with grant option;"
set password for [email protected] = password(‘123456‘);
create user zheng;
update user set authentication_string=password("123456") where user="zheng";
grant all on zheng.* to ‘zheng‘@‘10.116.39.147‘;
create user text;
update user set authentication_string=password("123456") where user="text";
grant all on text.* to ‘text‘@‘localhost‘;
3.刷新数据库 (一定要记得刷新)
mysql>flush privileges
本文出自 “饿狼的传说” 博客,请务必保留此出处http://9548010.blog.51cto.com/9538010/1869076
以上是关于mysql5.7编译安装的主要内容,如果未能解决你的问题,请参考以下文章