CentOS6.5编译安装MySQL 5.7.11

前端之家收集整理的这篇文章主要介绍了CentOS6.5编译安装MySQL 5.7.11前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

http://mirrors.sohu.com/mysql


安装前工作:
1,从官方网址下载MysqL5.7.11源码包,大概49M2,安装好CentOS6.5 64位操作系统。建议update操作系统,以便是此版本最新的3.yum -y install gcc gcc-c++ autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake libaio libaio-devel autoconf bzr bison libtoolmakecmakegcc-c++bisonncurses-devel//这是个人在安装老版本使用的,相关依赖包软件放在/data正式安装MysqL1. 添加MysqL用户和所属组groupadd MysqLuseradd -r -g MysqL MysqL

2. 解压源码包

mkdir /data

chmod755/data

cd /data

wgethttp://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.11.tar.gz
tar -zxvfMysqL-5.7.11.tar.gz

3. 开始踩MysqL的坑 设置好make编译的目录

cdMysqL-5.7.11

cmake \-DCMAKE_INSTALL_PREFIX=/data/MysqL\ // 安装根目录-DMysqL_DATADIR=/MysqL/data\ //数据库存储路径

-DMysqL_UNIX_ADDR=/tmp/MysqL.sock\ //这个最好换成 /data 下-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DEXTRA_CHARSETS=all \-DENABLED_LOCAL_INFILE=1 \-DDOWNLOAD_BOOST=1 \-DWITH_BOOST=/data/boost_1_59_0 //需要boost支持,这一点跟5.6版本的不一样

-- Configuring done
-- Generating done-- Build files have been written to: /root/MysqL-5.7.11到这里cmake完成,比较顺利

cmake-DCMAKE_INSTALL_PREFIX=/data/MysqL-DMysqL_DATADIR=/MysqL/data-DMysqL_UNIX_ADDR=/tmp/MysqL.sock-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DEXTRA_CHARSETS=all-DENABLED_LOCAL_INFILE=1-DDOWNLOAD_BOOST=1-DWITH_BOOST=/data/boost_1_59_0

5. make 操作#make //漫长的过程 主要看机器的配置

Linking CXX executable my_safe_process[100%] Built target my_safe_process

注意:
MysqL 5.6.19 版本编译后的文件包约2G //笔者一直使用的是5.6.19及以上版本MysqL5.7.11 编译安装对磁盘的需求也比以往的版本多很多,make之后的MysqL-5.7.11文件夹约4.8G开始编译前

#df-h

FilesystemSizeUsedAvailUse%Mountedon

/dev/mapper/VolGroup-lv_root27G4.5G21G19%/

tmpfs996M228K996M1%/dev/shm

/dev/sda1485M39M421M9%/boot

编译完成后:

9.5G16G38%/

此时如果执行make install 会因为磁盘不足,导致缺失重要的文件,笔者,尝试过几次,均失败。 最后的报错如下:-- Installing: /usr/local/MysqL/bin/MysqL_embeddedCMake Error at libMysqLd/examples/cmake_installNaNake:42 (FILE): file INSTALL cannot copy file "/root/MysqL-5.7.11/libMysqLd/examples/MysqL_embedded" to "/usr/local/MysqL/bin/MysqL_embedded".Call Stack (most recent call first): cmake_installNaNake:116 (INCLUDE)make: *** [install] Error 1并且5.7.11的安装文件也比以往略大5.6.19 ---->1.1G5.7.11 ---->1.9G所以建议大家尽量给多一点空间

6. make install安装:make install 从最后一行看到密码?........

-- Installing: /usr/local/MysqL/support-files/magic-- Installing: /usr/local/MysqL/share/aclocal/MysqL.m4-- Installing: /usr/local/MysqL/support-files/MysqL.server

7.初始化MysqL

cd /data/MysqL/bin

./MysqLd --initialize --user=MysqL --datadir=/data/MysqL/data --basedir=//MysqL --socket=/tmp/MysqL.sock //在MysqL5.7.6版本以前是bin/MysqL_install_db --user2016-02-25T04:36:27.941245Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2016-02-25T04:36:29.363359Z 0 [Warning] InnoDB: New log files created,LSN=457902016-02-25T04:36:29.529261Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2016-02-25T04:36:29.615486Z 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: 56a9ad19-db79-11e5-bc10-080027207e2e.2016-02-25T04:36:29.635578Z 0 [Warning] Gtid table is not ready to be used. Table 'MysqL.gtid_executed' cannot be opened.2016-02-25T04:36:29.645190Z 1 [Note] A temporary password is generated for root@localhost: oej<ibtee2r?

8. 添加MysqL服务

cd /data/MysqL-5.7.11/support-files

# cp MysqL.server /etc/init.d/MysqLdcd/etc/init.d/

chmod+xMysqLd

chmoda+wrx/tmp //给socket 存储文件 写的权限

9. 编辑my.cnf文件# vi /etc/my.cnf //添加下面的,这里为了简洁,省去其他的,都是按照默认的 注释掉以前的[MysqLd]port=3306basedir=/data/MysqLdatadir=/data/MysqL/datasocket=/tmp/MysqL.sock

[MysqLd]

port=3306

basedir=/data/MysqL

datadir=/data/MysqL/data

init_connect='setautocommit=0'

#datadir=/var/lib/MysqL

#socket=/var/lib/MysqL/MysqL.sock

#Disablingsymbolic-linksisrecommendedtopreventassortedsecurityrisks

#symbolic-links=0

#Settingsuserandgroupareignoredwhensystemdisused.

#IfyouneedtorunMysqLdunderadifferentuserorgroup,

#customizeyoursystemdunitfileformariadbaccordingtothe

#instructionsinhttp://fedoraproject.org/wiki/Systemd

[MysqLd_safe]

log-error=/var/log/mariadb/mariadb.log

pid-file=/var/run/mariadb/mariadb.pid

#

#includeallfilesfromtheconfigdirectory

10. 重启MysqL

chownMysqL.MysqL/data/MysqL/

# /etc/init.d/MysqLd restartStarting MysqL.. SUCCESS!

chkconfigMysqLdon

如果有报错可以删除/data/MysqL/data下的

ib_logfile1 ib_logfile0

rmib_logfile0

Y

再次启动

ps-ef|grepMysqLd

11. 登录MysqL

# cd/data/MysqL/bin

# ./MysqL -uroot -p //第一次登录MysqL,密码文件在,也可以从make install 最后的一行看到密码Enter password:

这边忘记MysqL的密码了 方法

vi /etc/my.cnf #编辑文件,找到[MysqLd],在下面添加一行skip-grant-tables

[MysqLd]

skip-grant-tables

:wq! #保存退出

service MysqLd restart #重启MysqL服务

cd/data/MysqL/bin

./MysqL-uroot-p #直接按回车,这时不需要输入root密码。

use MysqL

update user set authentication_string=PASSWORD('123456') where User='root';

flush privileges; #刷新系统授权表

grant all on *.* to 'root'@'localhost' identified by '123456' with grant option;

vi /etc/my.cnf 编辑文件,找到[MysqLd],删除skip-grant-tables这一行

:wq! #保存退出

service MysqLd restart #重启MysqL,这个时候MysqL的root密码已经修改为123456

MysqL -uroot -p #进入MysqL控制台

123456 #输入密码

MysqL> show warnings;+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+| Level | Code | Message //下面提示我那种方法以后将会被遗弃 || Warning | 1287 | 'SET PASSWORD = PASSWORD('')' is deprecated and will be removed in a future release. Please use SET PASSWORD = '' instead |1 row in set (0.00 sec)结束!

原文链接:https://www.f2er.com/centos/381865.html

猜你在找的CentOS相关文章