mysql5.7.11编译安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql5.7.11编译安装相关的知识,希望对你有一定的参考价值。
进入/usr/local/src
cd /usr/local/src
2.下载mysql 5.7.10
wget http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.11.tar.gz
3.安装组件 cmake必须安装
yum -y install gcc-c++ ncurses-devel cmake make perl yum -y gcc autoconf automake zlib libxml libgcrypt libtool bison yum -y install gcc gcc-c++ gcc-g77 autoconf automake yum -y zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake
4.添加用户
mysql安装的位置:
mkdir /usr/local/mysql
mysql data安装的位置:
mkdir /data/mysql
chown -R mysql:mysql /usr/local/mysql chown -R mysql:mysql /data/mysql chmod 777 /usr/local/mysql chmod 777 /data/mysql groupadd mysql useradd -r -g mysql mysql
5.解压mysql安装包
cd /usr/local/src/ tar -zxvf mysql-5.7.11.tar.gz cd mysql-5.7.11
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DMYSQL_USER=mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=./boost/ 由于我们下载的是mysql带boost包的,因此解压后,boost目录就在mysql解压 包下,路径为./boost/ 注意,boost后的“/” 必须要添加。
由于我下载的是自带boost的mysql,所以只要制定路径就可以了。
参数详解:
常用参数:
CMAKE_INSTALL_PREFIX:指定MySQL程序的安装目录,默认/usr/local/mysql
DEFAULT_CHARSET:指定服务器默认字符集,默认latin1
DEFAULT_COLLATION:指定服务器默认的校对规则,默认latin1_general_ci
ENABLED_LOCAL_INFILE:指定是否允许本地执行LOAD DATA INFILE,默认OFF
WITH_COMMENT:指定编译备注信息
WITH_xxx_STORAGE_ENGINE:指定静态编译到mysql的存储引擎,MyISAM,MERGE,MEMBER
以及CSV四种引擎默认即被编译至服务器,不需要特别指定。
WITHOUT_xxx_STORAGE_ENGINE:指定不编译的存储引擎
SYSCONFDIR:初始化参数文件目录
MYSQL_DATADIR:数据文件目录
MYSQL_TCP_PORT:服务端口号,默认3306
MYSQL_UNIX_ADDR:socket文件路径,默认/tmp/mysql.sock
------------------------------------------------------------------------------------------
网友的编译参数
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ [MySQL安装的根目录]
-DMYSQL_DATADIR=/mydata/mysql/data \ [MySQL数据库文件存放目录]
-DSYSCONFDIR=/etc \ [MySQL配置文件所在目录]
-DMYSQL_USER=mysql \ [MySQL用户名]
-DWITH_MYISAM_STORAGE_ENGINE=1 \ [MySQL的数据库引擎]
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ [MySQL的数据库引擎]
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \ [MySQL的数据库引擎]
-DWITH_MEMORY_STORAGE_ENGINE=1 \ [MySQL的数据库引擎]
-DWITH_READLINE=1 \ [MySQL的readline library]
-DMYSQL_UNIX_ADDR=/var/run/mysql/mysql.sock \ [MySQL的通讯目录]
-DMYSQL_TCP_PORT=3306 \ [MySQL的监听端口]
-DENABLED_LOCAL_INFILE=1 \ [启用加载本地数据]
-DENABLE_DOWNLOADS=1 \ [编译时允许自主下载相关文件]
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \ [使MySQL支持所有的扩展字符]
-DDEFAULT_CHARSET=utf8 \ [设置默认字符集为utf8]
-DDEFAULT_COLLATION=utf8_general_ci \ [设置默认字符校对]
-DWITH_DEBUG=0 \ [禁用调试模式]
-DMYSQL_MAINTAINER_MODE=0 \
-DWITH_SSL:STRING=bundled \ [通讯时支持ssl协议]
-DWITH_ZLIB:STRING=bundled [允许使用zlib library]
-------------------------------------------------------------------------------------------
make && make install
3.初始化mysql
记住一定要先把权限给mysql用户,否则初始化会报错。
chown -R mysql:mysql /data chown -R mysql:mysql /data/mysql chown -R mysql:mysql /usr/local/mysql
cd /usr/local/mysql/bin ./mysqld --initialize --datadir=/data/mysql --basedir=/usr/local/mysql/ --user=mysql 2016-03-06T05:31:01.664510Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-03-06T05:31:05.188724Z 0 [Warning] InnoDB: New log files created, LSN=45790 2016-03-06T05:31:05.571415Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2016-03-06T05:31:05.689390Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 9f7c61ff-e35c-11e5-9957-000c29d5b9a9. 2016-03-06T05:31:05.698274Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened. 此行为初始密码: 2016-03-06T05:31:05.700736Z 1 [Note] A temporary password is generated for [email protected]: Zi?gw66wnIgs
此行为初始密码:
2016-03-06T05:31:05.700736Z 1 [Note] A temporary password is generated for [email protected]: Zi?gw66wnIgs
4.拷贝标准启动脚本和配置文件
cd /usr/local/src/mysql-boost-5 [[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld [[email protected] mysql]# mv /etc/my.cnf /etc/my.cnf.old [[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf [[email protected] mysql]#chmod 755 /etc/init.d/mysqld
5.配置启动脚本和配置文件
[[email protected] mysql]# vim /etc/init.d/mysqld basedir=/usr/local/mysql datadir=/data/mysql mysqld_pid_file_path=/usr/local/mysql/mysql.pid [[email protected] mysql]# vim /etc/my.cnf basedir=/usr/local/mysql datadir=/data/mysql
6.设置mysql服务开机启动并启动mysql
[[email protected] mysql]# chkconfig --add mysqld [[email protected] mysql]# chkconfig mysqld on [[email protected] mysql]# service mysqld start Starting MySQL.. SUCCESS!
7.设置环境变量
vim /etc/profile 最后添加一行: export PATH=$PATH:/usr/local/mysql/bin 保存退出 然后: source /etc/profile
8.初始化mysql密码
mysql -uroot -p set password=password(‘yourpassword‘); alter user ‘root‘@‘localhost‘ password expire never; flush privileges;
本文出自 “清晰明了” 博客,请务必保留此出处http://duanyexuanmu.blog.51cto.com/1010786/1750043
以上是关于mysql5.7.11编译安装的主要内容,如果未能解决你的问题,请参考以下文章