Centos7 编译安装mysql5.6

来源:互联网 发布:js 分享 编辑:程序博客网 时间:2024/05/20 20:18

安装编译mysql所需要的软件

yum install gcc gcc-c++ ncurses-devel perl -ywget https://cmake.org/files/v3.9/cmake-3.9.0.tar.gztar xzvf cmake-3.9.0.tar.gzcd cmake-3.9.0/./bootstrap makemake install

创建mysql用户,安装目录和数据目录

groupadd mysqluseradd -r -g mysql mysql mkdir -p /usr/local/mysql mkdir -p /data/mysqldb 

下载mysql5.6的源码

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.16.tar.gz  tar xzvf mysql-5.6.16.tar.gz cd mysql-5.6.16/

编译安装

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mysqldb -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1rm CMakeCache.txtmakemake install 

修改mysql目录所有者和组

cd /usr/local/mysql/chown -R mysql:mysql .cd /data/mysqldb/chown -R mysql:mysql .

初始化数据

cd /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb

可能遇到问题

Can't locate Data/Dumper.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./mysql_install_db line 42. BEGIN failed--compilation aborted at ./mysql_install_db line 42.

解决方法

yum install 'perl(Data::Dumper)' -y

修改mysql配置文件

cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnfcp support-files/mysql.server /etc/init.d/mysqld vim /etc/my.cnf[mysqld]# Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128M# Remove leading # to turn on a very important data integrity option: logging# changes to the binary log between backups.# log_bin# These are commonly set, remove the # and set as required.  basedir = /usr/local/mysql  datadir = /data/mysqldb/  port = 3306  server_id = 136# socket = .....# Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.# join_buffer_size = 128M# sort_buffer_size = 2M# read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

加入path路径

vim /etc/profile在最后添加  PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH    export PATH  source /etc/profile    

启动mysql

service mysqld start

登录mysql

mysql -uroot

这里写图片描述

原创粉丝点击