CentOS 源码安装MySQL5.7

一、安装方式
源码安装,源码包名称mysql-boost-5.7.27.tar.gz,此版本包含boost库,在解压后的boost路径下。安装时,可以-DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/mysql-5.7.27/boost/指定boost路径

二、安装路径
基础路径 /usr/local/mysql
数据文件路径 /usr/local/mysql/data

三、安装依赖
yum -y install autoconf automake libtool cmake ncurses-devel openssl-devel lzo-devel zlib-devel gcc gcc-c++

四、添加用户信息
添加系统mysql组和mysql用户
添加系统mysql组 groupadd mysql
添加mysql用户 useradd -r -g mysql mysql (添加完成后可用id mysql查看)
切到mysql目录 cd /usr/local/mysql
修改当前目录拥有者为mysql用户 chown -R mysql.mysql ./

五、配置预编译
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DCOMPILATION_COMMENT="lq-edition" -DENABLE_DTRACE=0 -DOPTIMIZER_TRACE=1 -DWITH_DEBUG=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/mysql-5.7.27/boost/
出现如下警告
CMake Warning:
Manually-specified variables were not used by the project:
MYSQL_USER
WITH_READLINE
-- Build files have been written to: /usr/local/mysql-5.7.27
忽略即可。

六、编译和安装
编译 make
安装 make install
如果服务器内存较小,可以使用如下指令
make -j `grep processor /proc/cpuinfo | wc -l` #编译时会消耗很大内存,小内存可能无法编译完成

七、初始化数据库
cd /usr/local/mysql/bin/
./mysqld --initialize --user=mysql
获取到密码 ,/7Xa7Y#hN_X

八、开启ssl功能
cd /usr/local/mysql/bin/
./mysql_ssl_rsa_setup

九、测试启动mysql
cd /usr/local/mysql/bin/
./mysqld_safe --user=mysql
出现如下错误

mysqld_safe error:log-error set to ‘/var/log/mariadb/mariadb.log‘,however file does not exists,Create writable for you ‘mysql‘.

是mysql用户没有/var/log/mariadb/mariadb.log权限
执行如下操作
mkdir /var/log/mariadb
touch /var/log/mariadb/mariadb.log
chown -R mysql:mysql /var/log/mariadb

从新执行./mysqld_safe --user=mysql

执行成功

十、启动mysql服务并更改密码
cd /usr/local/mysql/support-files
./mysql.server start

上述方法一直报错,因为创建mysql用户的使用使用了chown -R mysql:mysql ./来配置/user/local/mysql目录的所属路径,但是该方法应该是ubuntu的指令,所以导致安装的时候数据库的权限出了问题,centos的指令应该是chown -R mysql.mysql ./,第四步已经更正,这里应该不会再出现此错误,如果还是出现此错误,按照如下方式操作。
这里为了正常启动数据库,而不用重装,采用如下方式
配置/etc/my.cnf文件如下

[mysqld]
datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
socket=/usr/local/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

然后执行如下指令,以root权限启动数据库
cd /usr/local/mysql/bin
./mysqld --user=root

十一、配置文件位置
/etc/my.cnf

十二、修改密码
SET PASSWORD FOR ‘root‘@‘%‘ = PASSWORD(‘password‘);

十三、添加环境变量
编辑 ~/.bashrc文件,vim ~/.bashrc,添加如下内容
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
执行如下指令,使环境变量生效
source ~/.bashrc

十四、运行数据库远程连接
执行下面命令
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘password‘ WITH GRANT OPTION;
刷新权限表
FLUSH PRIVILEGES;

CREATE DATABASE IF NOT EXISTS test_db default charset utf8 COLLATE utf8_general_ci;

–uroot –ppassword –Dtest_db

原文地址:https://www.cnblogs.com/youjile/p/11470208.html

时间: 2024-10-03 07:06:39

CentOS 源码安装MySQL5.7的相关文章

CentOS 源码安装MYSQL-5.6

一. 环境准备 Linux CentOS7.3系统一台主机即可: MYSQL官网:https://www.mysql.com/ MYSQL软件下载:http://ftp.kaist.ac.kr/mysql/Downloads/MySQL-5.6/ 二. MYSQL的编译和安装 1:准备工作 [[email protected] ~]# rpm -q mysql-server mysql                          //查看mysql是否已经安装 [[email protec

CentOS 6.5 源码安装MySQL5.6

CentOS 6.5 源码安装MySQL5.6 1:下载安装cmake (mysql5.5以后是通过cmake来编译的) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #http://download.csdn.net/detail/csxuedn/7976005 #wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz # tar -zxv -f /root/cmake-2.8.4.tar.gz

centos 7.4源码安装mysql5.5.20

安装环境: centos 7.4 + mysql 5.5.20 步骤: (1)     源码安装MYSQL5.5.20方法,通过cmake.make.make install三个步骤实现. 安装mysql需要的包:yum install -y cmake make gcc gcc-c++ wget ncurses-devel cmake make perl ncurses-devel openssl-devel bison-devel libaio libaio-devel PCRE是一个Per

源码安装mysql5.6.20&&mysql主从设置(多实例做多个主从)

一.源码安装mysql5.6.20 1.编译环境安装 yum install wget gcc* make openssl openssl-devel openssl-clients -y && yum groupinstall "Development Libraries" -y 2.源码下载(软件见Linux部署源码包) wget -P /usr/local/src/ http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.

MYSQL Study案例之--RedHat EL55源码安装Mysql-5.6

MYSQL  Study案例之--RedHat EL55源码安装Mysql-5.6 系统环境: 操作系统:RedHat EL55 DB Soft:  Mysql 5.6.4-m7 1.系统环境 [[email protected] Packages]# uname -a Linux rh6 2.6.18-194.el5.xen #1 SMP Tue Jan 29 11:47:41 EST 2013 i386 i686 GNU/Linux [[email protected] Packages]#

Linux下源码安装Mysql5.5

本文主要介绍了如何在源码安装mysql5.5,所用系统为CentOS6.5 一.安装相应的开发环境 yum install -y ncurses-devel yum install -y libaio yum install -y bison yum install -y gcc-c++ yum install -y openssl-devel 二.安装cmake 跨平台编译器 # tar xf cmake-2.8.8.tar.gz # cd cmake-2.8.8 # ./bootstrap

源码安装mysql5.6x启动报错:[ERROR] Can't find messagefile '/data/mysqldata/3306/english/errmsg.sys'

170502 10:43:40 mysqld_safe Starting mysqld daemon with databases from /data/mysqldata/3306/data 2017-05-02 10:43:40 0 [Warning] The syntax '--language/-l' is deprecated and will be removed in a future release. Please use '--lc-messages-dir' instead.

一、源码安装mysql5.6-单实例

一.源码安装mysql5.6-单实例 1.  安装前检查系统环境 1.1 操作系统版本及内核版本 [[email protected] ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.5 (Santiago) [[email protected] ~]# uname –r 2.6.32-431.el6.x86_64 1.2 selinux是否处于关闭状态 [[email protected] ~]# ge

CentOS-6.4-minimal版中源码安装MySQL-5.5.38

/** * CentOS-6.4-minimal版中源码安装MySQL-5.5.38 * ---------------------------------------------------------------------------------------------------------------------- * 三种安装方式 * 1)源码安装 * 2)二进制包安装 * 3)rpm或yum安装 * 本文演示的是源码安装,并且,从mysql-5.5开始,源码安装要通过cmake安装