CentOS7编译安装MySQL 5.7.22

CentOS7编译安装MySQL 5.7.22

1.下载源码包

在mysql官网选择合适的版本,得到下载的url

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22.tar.gz 或者直接修改url

或者使用wget命令下载

cd /usr/local/src

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22.tar.gz

下载完成之后解压安装包

tar -zxvf mysql-5.7.22.tar.gz

下载boost

wget http://www.sourceforge.net/projects/boost/files/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

进入mysql安装包

cd /usr/local/src/mysql-5.7.22

2.安装

卸载CentOS7默认携带的mariadb包

rpm -qa | grep -i mysql

rpm -qa | grep -i mariadb

卸载:

rpm -e mariadb-libs-5.5.56-2.el7.x86_64 –nodeps

安装一些依赖库

yum -y install cmake gcc gcc-c++ bison ncurses ncurses-devel bison perl autoconf cmake -y

创建用户组和用户

groupadd mysql

useradd -g mysql -s /sbin/nologin -M mysql

编译安装:

cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/cnet/data \

-DWITH_BOOST=/usr/local/boost \

-DSYSCONFDIR=/etc \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DWITH_FEDERATED_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DENABLED_LOCAL_INFILE=1 \

-DENABLE_DTRACE=0 \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_EMBEDDED_SERVER=1 \

-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock

————————————————————————————————————————-

make 报错c++: internal compiler error: Killed (program cc1plus)

[ 59%] Built target sql_dd

[ 60%] Built target slave

[ 60%] Building CXX object sql/CMakeFiles/sql_gis.dir/item_geofunc_setops.cc.o

c++: internal compiler error: Killed (program cc1plus)

Please submit a full bug report,

with preprocessed source if appropriate.

See <http://bugzilla.redhat.com/bugzilla> for instructions.

make[2]: *** [sql/CMakeFiles/sql_gis.dir/item_geofunc_setops.cc.o] Error 4

make[1]: *** [sql/CMakeFiles/sql_gis.dir/all] Error 2

make: *** [all] Error 2

内存不足,可以增加swap 交换分区 或者 加大物理内存

————————————————————————————————————————-

3.配置

设置权限 chown -R mysql:mysql /usr/local/mysql

添加配置文件

vi /etc/my.cnf

写入

[client]

port=3306

[mysql]

default-character-set=utf8

[mysqld]

port=3306

basedir=/usr/local/mysql

datadir=/cnet/data

character-set-server=utf8

default-storage-engine=InnoDB

max_connections=512

query_cache_size=0

tmp_table_size=18M

thread_cache_size=8

myisam_max_sort_file_size=64G

myisam_sort_buffer_size=35M

key_buffer_size=25M

read_buffer_size=64K

read_rnd_buffer_size=256K

sort_buffer_size=256K

innodb_flush_log_at_trx_commit=1

innodb_log_buffer_size=1M

innodb_buffer_pool_size=47M

innodb_log_file_size=24M

innodb_thread_concurrency=8

初始化mysql:

/usr/local/mysql/bin/mysqld \

–initialize-insecure \

–user=mysql \

–basedir=/usr/local/mysql \

–datadir=/cnet/data

添加MySQL环境变量

vi /etc/profile

最后一行增加

PATH=$PATH:/usr/local/mysql/bin

export PATH

刷新环境变量:

source /etc/profile

设置开机自启动

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

chkconfig –add mysqld

启动mysql

mysqld_safe –defaults-file=/etc/my.cnf &

查看mysql进程

ps -ef | grep mysql

netstat -ntlup | grep 3306

登陆MySQL

mysql -uroot

本文版权归 飞翔沫沫情 作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出 原文链接 如有问题, 可发送邮件咨询,转贴请注明出处:https://www.fxkjnj.com/405/

发表评论

登录后才能评论