Mysql5.6.21源码安装

Mysql5.6.21安装篇

做了3年运维,个人笔记倒是挺多,没有好好整理,有分享精神,比较懒,大学注册的账号,但是一直没有写过任何技术文档,羞愧。很认同一句话,搞技术一定要有分享精神,最讨厌那种以为自己很牛B,不理会新手装B的人,认同的给我点赞啊。当然请教长者,要把问题描述清晰,能百度,谷歌解决的小问题还是先自己去找资料。

环境描述

安装包:mysql-5.6.21.tar.gz

系统环境:Centos6.5

描述:安装的系统都是最小化的方式,勾选了基础,就下一步安装了,因为都是实验环境。系统配置没有太多的要求。虚拟机。内存只分配了512Mb内存,所以大家的mysql.cnf文件,根据生产情况去分配。

(1)依赖包安装

#yum install wget bison gcc gcc-c++ wget make cmake ncurses-devel libtool zilib-devel -y

(2)安装包下载,为懒人提供下载连接,连接失效的自行下载。

#wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.21.tar.gz

(3)规划好目录,尤其生产中。别搞得乱七八糟,维护的系统都需一套统一的目录体系结构。交接工作也一目了然。带新人,别人也看得懂。大伙赞同吧,哈哈

#mkdir -p /data/mysqldata/{3306/{data,tmp,binlog,redo-log,undo-log},backup,scripts}

(4)创建mysql用户,授权.

#groupadd mysql

#useradd -g mysql mysql

#chown mysql:mysql -R /data/mysqldata

(5)解压包,编译安装。

#tar zxvf mysql-5.6.21.tar.gz

#cd mysql-5.6.21

5.1:生成编译配置文件

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql56 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \

-DENABLED_LOCAL_INFILE=ON \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_FEDERATED_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_EXAMPLE_STORAGE_ENGINE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \

-DCOMPILATION_COMMENT=‘JSS for mysqltest‘ \

-DWITH_READLINE=ON \
-DSYSCONFDIR=/data/mysqldata/3306 \

-DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock

5.2:编译参数描述,这里简单解释下。

DCMAKE_INSTALL_PREFIX mysql安装目录,这里指的是mysql软件的安装路径,
DDEFAULT_CHARSET 指定mysql的字符集。
DDEFAULT_COLLATION 指定mysql服务的默认校对规则。
DENABLED_LOCAL_INFILE
是否允许从客户端本地加载数据到Mysql服务端,专用于load data infile语句,默认不允许

DWITH_*_STORAGE_ENGINE 静态编译某种存储引擎。*表示存储引擎名称,1表示开启。
DCOMPILATION_COMMENT 编译信息,后面启动的时候会看到。
DWITH_READLINE mysql输入输出的处理方式
DSYSCONFDIR mysql参数文件的默认路径
DMYSQL_UNIX_ADDR 套接字文件存储路径位置

描述:

以上很多信息都可以安装完成后,在my.cnf文件进行修改。如果编译过程出错,或者参数弄错,可以删除目录下的Cmakecache.txt文件,重新执行cmake,或者重新解压编译即可。

5.3:执行编译和安装

#make

#make install

5.4:授权,因为我是用root用户进行安装,但为了安全性。这部很重要啊,不要忘记了。。。

chown mysql:mysql -R /usr/local/mysql56

(6)编辑配置文件,注意,改操作是在mysql用户下操作。

#su - mysql

[[email protected] ~]$vim /data/mysqldata/3306/my.cnf

配置文件也规划好,不同类别位置对方整齐。

[client]

port = 3306
socket = /data/mysqldata/3306/mysql.sock

#Mysql Server
[mysqld]
port = 3306
user = mysql
socket = /data/mysqldata/3306/mysql.sock
pid-file = /data/mysqldata/3306/mysql.pid
basedir = /usr/local/mysql56
datadir = /data/mysqldata/3306/data
tmpdir = /data/mysqldata/3306/tmp
open_files_limit = 512
explicit_defaults_for_timestamp
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

#Buffer
max_allowed_packet = 64M
max_heap_table_size = 64M
net_buffer_length = 8K
sort_buffer_size = 2M
join_buffer_size =4M
read_buffer_size = 2M
read_rnd_buffer_size = 16M

#Log
log-bin = /data/mysqldata/3306/binlog/mysql-bin
binlog_cache_size = 16m
max_binlog_cache_size = 128m
max_binlog_size = 128m
binlog_format = mixed
log_output = FILE
log-error = ../mysql-error.log
slow_query_log = 1
slow_query_log_file = ../slow_query.log
general_log = 0
general_log_file = ../general_query.log
expire-logs-days = 14

#master-slave
server-id = 1
binlog-ignore-db = test
log-slave-updates
replicate-ignore-db = test

#InnoDB
innodb_data_file_path = libdata1:1024M:autoextend
innodb_log_file_size = 32M
innodb_log_files_in_group =6
innodb_log_group_home_dir = /data/mysqldata/3306/redo-log/
innodb_buffer_pool_size = 200M
sync_binlog = 8

#Undo Logs这里被我注释了,5.6版本undo可以拆分出来,貌似用xtrabackup恢复有问题,就注释了。
#innodb_undo_directory = /data/mysqldata/3306/undo-log/
#innodb_undo_log = 64
#innodb_undo_tablespaces = 16

[mysql]
no-auto-rehash
prompt=(\\[email protected]\\h) [\\d]>\\_

6.1:部分参数详解




(7)初始化数据库。

$/usr/local/mysql56/scripts/mysql_install_db --datadir=/data/mysqldata/3306/data --basedir=/usr/local/mysql56

结果如下:


Installing MySQL system tables...OK

Filling help tables...OK

To start mysqld at boot time you have to copy

support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

/usr/local/mysql56/bin/mysqladmin -u root password ‘new-password‘

/usr/local/mysql56/bin/mysqladmin -u root -h image04.com password ‘new-password‘

Alternatively you can run:

/usr/local/mysql56/bin/mysql_secure_installation

which will also give you the option of removing the test

databases and anonymous user created by default.  This is

strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

cd . ; /usr/local/mysql56/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

WARNING: Found existing config file /usr/local/mysql56/my.cnf on the system.

Because this file might be in use, it was not replaced,

but was used in bootstrap (unless you used --defaults-file)

and when you later start the server.

The new default config file was created as /usr/local/mysql56/my-new.cnf,

please compare it with your file and take the changes you need.

注释:

看到以上结果,那么恭喜你成功了,如果报错,或者没有看到的同学,也不要慌张,打开日志文件/data/mysqldata/3306/mysql-error.log,查看详情。多数原因都是因为配置文件出错导致。找出问题后,进行修改,然后删除/data/mysqldata/3306{data,redo,binlog}目录下的文件,然后重新执行初始化命令即可。

在我执行的结果看,出现了Warning,这个结果可以忽略,像我上面的结果,在初始化前,可以执行删除配置文件,/usr/local/mysql56/my.cnf,/usr/local/mysql56/my-new.cnf,/etc/my.cnf,如果这些文件存在,可以清除掉。就发现warning消失了。

(8)启动数据库,我这里采用sale的方式启动。

$/usr/local/mysql56/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf &

结果如下

[[email protected] 3306]$ /usr/local/mysql56/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf &

[1] 28848

[[email protected] 3306]$ 150403 19:59:32 mysqld_safe Logging to ‘/data/mysqldata/3306/data/../mysql-error.log‘.

150403 19:59:32 mysqld_safe Starting mysqld daemon with databases from /data/mysqldata/3306/data

8.1:查看启动状态

$ps -ef | grep mysql

$netstat -ano | grep 3306


[[email protected] 3306]$ ps -ef | grep mysql

root     27864  1558  0 17:42 pts/0    00:00:00 su - mysql

mysql    27866 27864  0 17:42 pts/0    00:00:00 -bash

mysql    28848 27866  0 19:59 pts/0    00:00:00 /bin/sh /usr/local/mysql56/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf

mysql    29386 28848  0 19:59 pts/0    00:00:00 /usr/local/mysql56/bin/mysqld --defaults-file=/data/mysqldata/3306/my.cnf --basedir=/usr/local/mysql56 --datadir=/data/mysqldata/3306/data --plugin-dir=/usr/local/mysql56/lib/plugin --log-error=/data/mysqldata/3306/data/../mysql-error.log --open-files-limit=512 --pid-file=/data/mysqldata/3306/mysql.pid --socket=/data/mysqldata/3306/mysql.sock --port=3306

[[email protected] 3306]$ netstat -ano | grep 3306

tcp        0      0 :::3306                     :::*                        LISTEN      off (0.00/0/0)

unix  2      [ ACC ]     STREAM     LISTENING     80061  /data/mysqldata/3306/mysql.sock

(9)进入数据库

注释:默认mysql管理员账户是没有设置密码的,前面初始化后的信息,已经告诉我们怎么去设置密码。

$/usr/local/mysql56/bin/mysql


[[email protected] 3306]$ /usr/local/mysql56/bin/mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.21-log JSS for mysqltest

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

([email protected]) [(none)]>

(10)关闭数据库

$ /usr/local/mysql56/bin/mysqladmin -S /data/mysqldata/3306/mysql.sock shutdown

结果如下:


[[email protected] 3306]$ /usr/local/mysql56/bin/mysqladmin -S /data/mysqldata/3306/mysql.sock shutdown

150403 21:09:30 mysqld_safe mysqld from pid file /data/mysqldata/3306/mysql.pid ended

[1]+  Done                    /usr/local/mysql56/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf

[[email protected] 3306]$ netstat -ano | grep 3306

[[email protected] 3306]$ ps -el | grep mysql

时间: 2024-10-21 23:43:10

Mysql5.6.21源码安装的相关文章

mysql5.7.21源码安装

1.下载安装包 MySQL 官方下载地址:https://dev.mysql.com/downloads/mysql/ MySQL 5.7官方安装文档:https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html 2.安装依赖包 MySQL依赖于libaio 库.如果这个库没有在本地安装,数据目录初始化和后续的服务器启动步骤将会失败.请使用适当的软件包管理器进行安装.例如,在基于Yum的系统上: shell> yum searc

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