mysql5.7.9 源码安装 (转)

1,安装所有包

yum -y install gcc-c++ ncurses-devel cmake make perl gcc autoconf automake zlib libxml libgcrypt libtool bison python-devel

2,创建用户,目录,权限

groupadd mysql
useradd -r -g mysql -s /bin/false mysql

mkdir /usr/local/mysql  软件目录
mkdir -p /usr/local/mysql/data   数据目录
mkdir -p /var/log/mysql     日志路径
mkdir -p /var/run/mysql     pid路径

-- 用户属主

chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /mydata/mysql/data
chown -R mysql:mysql /var/log/mysql
chown -R mysql:mysql /var/run/mysql

另外如果有登陆固需求:

设置vim  /etc/security/limits.conf

mysql   soft   nproc  2047

mysql   hard  nproc  16384

mysql   soft   nofile  1024

mysql  hard   nofile  65536

环境变量:

vim /home/mysql/.bash_profile

export  LANG=zh_CN.GB18030

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

3,安装一些配置,工具包

gmock ,地址http://git.typecodes.com/libs/ccpp/gmock-1.6.0.zip
安装步骤,解压到mysql-5.7.9的source_downloads目录,可选步骤
安装cmake,可以使用yum安装或者下载安装,下载路经http://git.typecodes.com/libs/ccpp/cmake-3.2.1.tar.gz
安装ncurses-devel,yum安装
GNU分析器生成器,连接http://git.typecodes.com/libs/ccpp/bison-3.0.tar.gz
boost请看第四部分析

4,编译&&安装

tar zxvf mysql-5.7.9.tar.gz
cd mysql-5.7.9
第一部:cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql 
-DMYSQL_DATADIR=/mydata/mysql/data  -DSYSCONFDIR=/etc -DMYSQL_USER=mysql
-DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DMYSQL_UNIX_ADDR=/var/run/mysql/mysql.sock -DMYSQL_TCP_PORT=3306
-DENABLED_LOCAL_INFILE=1 -DENABLE_DOWNLOADS=1
-DWITH_PARTITION_STORAGE_ENGINE=1  -DEXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
-DWITH_DEBUG=0 -DMYSQL_MAINTAINER_MODE=0
-DWITH_SSL:STRING=bundled -DWITH_ZLIB:STRING=bundled
-DWITH_BOOST=/usr/local/boost
第二部:make && make install
说明
-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]
-DWITH_BOOST=/usr/local/boost                [boost库地址,如果安装了,可以不用指定]
中间遇到两个问题,
第一,CMake Error at cmake/boost.cmake:76 (MESSAGE)
You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>
解决方法:追加编译选项-DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost或者将
http://sourceforge.net/projects/boost/files/boost/1.59.0
/boost_1_59_0.tar.gz下载到/usr/local/boost
再追加编译选项-DWITH_BOOST=/usr/local/boost
这个一定要匹配,mysql-5.7.9可能需要安装boost_1_59_0以上版本的
第二,Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)
解决:
rm CMakeCache.txt
yum install ncurses-devel

其实这个根据提示就可以看出来了

第三,安装boost的时候,提示很多python库没找到

yum install python-devel

5,配置文件

我们安装时配置的路径是etc,这里有个默认的文件my.cnf,修改内容为类似如下
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It‘s a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[client]
port=3306
socket=/var/run/mysql/mysql.sock

[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.
user = mysql
basedir = /usr/local/mysql
datadir = /mydata/mysql/data
port=3306
server-id = 1
socket=/var/run/mysql/mysql.sock

character-set-server = utf8
log-error = /var/log/mysql/error.log
pid-file = /var/log/mysql/mysql.pid
general_log = 1
skip-name-resolve
#skip-networking
back_log = 300

max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M

read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 28M
key_buffer_size = 4M

thread_cache_size = 8

query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M

ft_min_word_len = 4

log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30

performance_schema = 0
explicit_defaults_for_timestamp

#lower_case_table_names = 1

#default-storage-engine=myism
#innodb_buffer_pool_size=2048M
#innodb_log_file_size=1024M

myisam_sort_buffer_size = 8M
myisam_repair_threads = 1

interactive_timeout = 28800
wait_timeout = 28800

# 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

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER,STRICT_TRANS_TABLES

[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M

6,初始化数据库

/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/mydata/mysql/data
这部很重要,如果初始库不能创建,服务是岂不来的

7,设置系统服务,开机子启动

cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld  
chkconfig --add mysql
chkconfig mysqld on

8,启动服务

mysqld_safe --user=mysql --datadir=/mydata/mysql/data --log-error=/var/log/mysql/error.log &
service mysqld start
不懂两者关系摆渡
查看启动情况:ps -ef | grep mysql,netstat -tunpl | grep 3306

9,初始化配置

mysql_secure_installation
根据需要配置一些root密码,是否匿名访问,是否远程访问,删除test库等操作

10,创建用户等

mysql -uroot -p
create database `mysqldb` default character set utf8 collate utf8_general_ci;
grant all privileges on mysqldb.* to [email protected] identified by ‘china123‘;
flush privileges;

说明:mysql比较特殊,不像oracle,授权即可创建新用户

时间: 2024-11-05 14:54:55

mysql5.7.9 源码安装 (转)的相关文章

mysql-5.5.28源码安装过程中错误总结

介绍一下关于mysql-5.5.28源码安装过程中几大错误总结,希望此文章对各位同学有所帮助.系统centOS 6.3 mini (没有任何编译环境)预编译环境首先装了众所周知的 cmake(yum install cmake -y) 复制代码 代码如下: ../bootstrap Error when bootstrapping CMake: Cannot find appropriate C compiler on this system. Please specify one using

mysql5.5.30源码安装及主从搭建

双机热备(实验环境) 主服务器:ip地址192.168.100.244,mysql版本5.5.30,源码安装 从服务器:ip地址192.168.100.245 一.源码安装mysql5.5 启动目录:/usr/local/mysql 数据文件目录:/data/mysql 二进制日志目录:/data/mysql/binlog 1.添加mysql 用户(不添加用户目录) shell> groupadd mysql shell> useradd -r -g mysql mysql -g, --gid

mysql5.7.17源码安装

创建用户和目录 groupadd mysql useradd -r -g mysql mysql mkdir -p /data/mysql/standby/data mkdir -p /data/mysql/standby/tmp mkdir -p /data/mysql/standby/elog mkdir -p /data/mysql/standby/blog chown -R mysql:root /data/mysql 配置yum源 cd /etc/yum.repos.d/ rm -rf

Centos7.1 for MySQL5.6.30源码安装

预备工作: OS:Centos7.1 DATABASE: mysql-5.6.30.tar.gz 1. 创建mysql帐号 创建用户和用户组   [[email protected] ~]# groupadd mysql       [[email protected] ~]# useradd -g mysql mysql   [[email protected] ~]# passwd mysql 2.验证安装包 先验证之前是否安装过mysql,若存在mysql相关包,则rpm -e逐个删除(建

mysql-5.6.27源码安装及错误解决办法

环境:centos6.5.x86_64 wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.27.tar.gz yum install -y cmake  当然也可以自己下载源码包安装,为方便就Yum安装了 useradd -s /sbin/nologin mysql tar zxvf mysql-5.6.27.tar.gz mkdir -p /data/mysql chown -R mysql:mysql /data/mysql cd

CentOs7 64位 mysql-5.6.35源码安装

首先安装依赖包,避免在安装过程中出现问题 [ro[email protected] liuzhen]# yum -y install gcc gcc-c++ [[email protected] liuzhen]# yum -y install cmake [[email protected] liuzhen]# yum -y install ncurses-devel [[email protected] liuzhen]# yum -y install autoconf [[email pr

mysql5.6.30 源码安装

下载MySQL-5.6.30-1.el6.src.rpm源码 MySQL-5.6.30-1.el6.src.rpm下载地址 rpm -ivh MySQL-5.6.30-1.el6.src.rpm rpmbuild/SOURCES/mysql-5.6.30.tar.gz 依赖包安装 yum install cmake ncurses-devel bison-devel libaio-devel gcc-c++ 创建mysql用户 groupadd mysql useradd mysql -g my

centos7 mysql5.7.17源码安装

**安装前准备 操作系统环境:Centos 7.2 1.解决依赖包并下载源码包至/home/soft/目录下 [[email protected] ~]# yum -y install gcc gcc-c++ ncurses ncurses-devel cmake bison [[email protected] ~]# cd /home/soft/ [[email protected] soft]# wget https://sourceforge.net/projects/boost/fil

mysql5.5.17源码安装

1. 源码包下载 源码包通常也采用tar.gz压缩,名称中只包含版本信息,大小也比RPM包.二进制包小很多,解压后的文件中含有INSTALL-SOURCE文件,可从MySQL官网(http://www.mysql.com/downloads/)下载,如:mysql-5.5.17.tar.gz 2. CMake 在采用源码包安装MySQL实例之前,先来介绍一下cmake这个编译工具.在MySQL 5.5之前,是采用configure工具执行源码编译的,到了MySQL 5.5,改用cmake进行编译

mysql-5.6.40 源码安装(Centos6.6)

1. 检测系统是否自带有mysql [[email protected] ~]# rpm -qa|grep mysql mysql-libs-5.1.73-3.el6_5.x86_64 若有则卸载 [[email protected] ~]# rpm -e mysql-libs-5.1.73-3.el6_5.x86_64 --nodeps [[email protected] ~]# echo $? 0 2. 安装相关依赖包 [[email protected] ~]# yum -y insta