linux上源码编译安装mysql-5.6.28

在 linux 上编译安装 mysql-5.6.28.tar.gz
http://www.mysql.com/
mysql下载地址:
http://www.mysql.com/downloads/mysql/#downloads
mysql 官方网站文档:
https://dev.mysql.com/doc/

01、准备工作

yum install -y gcc gcc-c++ cmake make ncurses ncurses-devel  bison

02、解压

tar zxf mysql-5.6.28.tar.gz

03、编译

cmake . -DCMAKE_INSTALL_PREFIX=/tmp/test/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_EXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci

make -j 8
make install -j 8   

注意:
常见的CMAKE选项
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql    MySQL安装目录
-DWITH_INNOBASE_STORAGE_ENGINE=1           安装InnoDB存储引擎
-DWITH_MYISAM_STORAGE_ENGINE=1             安装MyISAM存储引擎
-DWITH_MEMORY_STORAGE_ENGINE=1             安装内存存储引擎
-DDEFAULT_CHARSET=utf8                     默认编码设置成utf8
-DDEFAULT_COLLATION=utf8_general_ci        默然校验规则是utf8_general_ci
-DWITH_EXTRA_CHARSETS=all                  支持其他所有的编码
-DMYSQL_TCP_PORT=3306                      MySQL端口指定为3306
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock          指定SOCK文件路径
-DMYSQL_DATADIR=/usr/local/mysql/data      MySQL数据目录

make -j n  支持多线程编译(一般跟内核数相等)

04、配置my.cnf
[[email protected] mysql]# pwd
/tmp/test/mysql
mkdir conf
cp support-files/my-default.cnf  conf/
vim my.cnf 详情看下面的附属
05、初始化数据库

useradd mysql
#注意  --user  需要用root编译
./scripts/mysql_install_db --defaults-file=/tmp/test/mysql/my.cnf   --user=mysql

./scripts/mysql_install_db --defaults-extra-file=/tmp/test/mysql/conf/my.cnf --user=mysql

06、启动数据库

./bin/mysqld_safe --defaults-file=/tmp/test/mysql/my.cnf --user=mysql &

./bin/mysqld_safe --defaults-extra-file=/tmp/test/mysql/conf/my.cnf --user=mysql &

07、设置密码
[[email protected] ~]# ss -ln |grep 3333
LISTEN     0      80                       :::3333                    :::*   

./bin/mysqladmin -u root password ‘123123‘

08、账户授权

grant all on *.* to ‘mvpbang‘@‘%‘ identified by ‘123123‘;
flush  privileges;

09、设置系统环境变量

vim /etc/profile
export PATH=$PATH://tmp/test/mysql/bin

source /etc/profile
修改 rc.local ,让 mysql 开机自动运行
echo "mysqld_safe --defaults-extra-file=/tmp/test/mysql/conf/my.cnf --user=mysql &" >>/etc/rc.local

10、基本命令的参数说明
[[email protected] mysql]# ./scripts/mysql_install_db --help
Usage: ./scripts/mysql_install_db [OPTIONS]
  --basedir=path       The path to the MySQL installation directory.
  --builddir=path      If using --srcdir with out-of-directory builds, you
                       will need to set this to the location of the build
                       directory where built files reside.
  --cross-bootstrap    For internal use.  Used when building the MySQL system
                       tables on a different host than the target.
  --datadir=path       The path to the MySQL data directory.
                       If missing, the directory will be created, but its
                       parent directory must already exist and be writable.
  --defaults-extra-file=name
                       Read this file after the global files are read.
  --defaults-file=name Only read default options from the given file name.
  --force              Causes mysql_install_db to run even if DNS does not
                       work.  In that case, grant table entries that
                       normally use hostnames will use IP addresses.
  --help               Display this help and exit.
  --ldata=path         The path to the MySQL data directory. Same as --datadir.
  --no-defaults        Don‘t read default options from any option file.
  --keep-my-cnf        Don‘t try to create my.cnf based on template.
                       Useful for systems with working, updated my.cnf.
                       Deprecated, will be removed in future version.
  --random-passwords   Create and set a random password for all root accounts
                       and set the "password expired" flag,
                       also remove the anonymous accounts.
  --rpm                For internal use.  This option is used by RPM files
                       during the MySQL installation process.
  --skip-name-resolve  Use IP addresses rather than hostnames when creating
                       grant table entries.  This option can be useful if
                       your DNS does not work.
  --srcdir=path        The path to the MySQL source directory.  This option
                       uses the compiled binaries and support files within the
                       source tree, useful for if you don‘t want to install
                       MySQL yet and just want to create the system tables.
  --user=user_name     The login username to use for running mysqld.  Files
                       and directories created by mysqld will be owned by this
                       user.  You must be root to use this option.  By default
                       mysqld runs using your current login name and files and
                       directories that it creates will be owned by you.
Any other options are passed to the mysqld program.

[[email protected] mysql]# ./bin/mysqld_safe --help
Usage: ./bin/mysqld_safe [OPTIONS]
  --no-defaults              Don‘t read the system defaults file
  --defaults-file=FILE       Use the specified defaults file
  --defaults-extra-file=FILE Also use defaults from the specified file
  --ledir=DIRECTORY          Look for mysqld in the specified directory
  --open-files-limit=LIMIT   Limit the number of open files
  --core-file-size=LIMIT     Limit core files to the specified size
  --timezone=TZ              Set the system timezone
  --malloc-lib=LIB           Preload shared library LIB if available
  --mysqld=FILE              Use the specified file as mysqld
  --mysqld-version=VERSION   Use "mysqld-VERSION" as mysqld
  --nice=NICE                Set the scheduling priority of mysqld
  --plugin-dir=DIR           Plugins are under DIR or DIR/VERSION, if
                             VERSION is given
  --skip-kill-mysqld         Don‘t try to kill stray mysqld processes
  --syslog                   Log messages to syslog with ‘logger‘
  --skip-syslog              Log messages to error log (default)
  --syslog-tag=TAG           Pass -t "mysqld-TAG" to ‘logger‘

All other options are passed to the mysqld program.

附上my.cnf

[client]
default-character-set=utf8

[mysql]
auto-rehash
default-character-set=utf8

[mysqld]
#根据实际情况适当调整
innodb_buffer_pool_size = 128M
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M 

#个性化设置
lower_case_table_names=1  #忽略大小写
  #对大批量数据导入导出防止超时
max_allowed_packet=500M
wait_timeout=200000
interactive_timeout=200000

#数据库字符集设置(由于编译已经选择,顾不需要设置)

#init_connect=‘SET collation_connection = utf8_unicode_ci‘
#init_connect=‘SET NAMES utf8‘
#character-set-server=utf8
#collation-server=utf8_unicode_ci

#日志记录
#log_bin

#基本信息
basedir = /tmp/test/mysql
datadir = /tmp/test/mysql/data
port = 3333
server_id = 1
socket = /tmp/test/mysql/data/mysql.sock

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

[mysqld_safe]
log-error = /tmp/test/mysql/life.log
pid-file = /tmp/test/mysql/data/mysqld.pid

内核编译进度

注意:配置低的编译基本上都是1个小时左右!!!(一般建议放在服务器上编译开多线程)

时间: 2024-10-25 20:45:07

linux上源码编译安装mysql-5.6.28的相关文章

在CentOS 7上源码编译安装MySQL 5.7

1.系统环境 [[email protected]inux02 ~]# uname -r 3.10.0-514.el7.x86_64 [[email protected] ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [[email protected] ~]# rpm -qa | grep mariadb mariadb-libs-5.5.52-1.el7.x86_64 [[email protected] ~

linux下源码编译安装mysql详解

1.redhat5环境下,首先安装编译环境 yum groupinstall -y  "Development Libraries"   "Development Tools" 2.由于源码编译mysql需要cmake命令,所以先要编译安装cmake包 首先下载cmake包,这里下载使用cmake-2.8.8.tar.gz tar xf cmake-2.8.8.tar.gz cd cmake-2.8.8 ./configure make && mak

linux学习笔记——源码编译安装Mysql

#######Redhat6.5源码编译安装Mysql########实验环境:1.IP:172.25.8.32.磁盘要大于20G先添加一块大于20G的磁盘fdisk /dev/vdb        ##得到/dev/vdb1 8e linuxpvcreate /dev/vdb1    ##把物理分区做成物理卷vgextend vg_server1 /dev/vdb1    ##把新建立的/dev/vdb1添加到vg_server1中lvextend -L 20G /dev/vg_server1

CentOS 6.6 下源码编译安装MySQL 5.7.5

版权声明:转自:http://www.linuxidc.com/Linux/2015-08/121667.htm 说明:CentOS 6.6 下源码编译安装MySQL 5.7.5 1. 安装相关工具# yum -y install gcc-c++ ncurses-devel cmake make perl \ gcc autoconf automake zlib libxml libgcrypt libtool bison2. 清理环境检查boost版本: # rpm -qa boost*卸载b

CentOS源码编译安装MySQL 5.5.15

CentOS源码编译安装MySQL 5.5.15 文章目录 [隐藏] 安装编译工具 下载源码 安装cmake和bison 编译安装MySQL 一些相关设置 安装编译工具 yum install gcc gcc-c++ yum install ncurses-devel 下载源码 mkdir -p /tmp cd /tmp wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.15.tar.gz/from/http://mysql.

Linux下源码编译安装rpy2

R(又称R语言)是一款开源的跨平台的数值统计和数值图形化展现工具.rpy2是Python直接调用R的第三方库,它可以实现使用python读取R的对象.调用R的方法以及Python与R数据结构转换等.这里主要介绍一下在没有网络的情况下,源码安装rpy2的一些方法,以作备忘. 1.python安装 $ wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz $ tar zvxf Python-2.7.6.tgz $ cd Pytho

SUSE Linux源码编译安装MySQL 5.6

这篇文章主要介绍了SUSE Linux下源码编译方式安装MySQL 5.6过程分享,本文使用SUSE Linux Enterprise Server 10 SP3 (x86_64)系统,需要的朋友可以参考下.MySQL为开源数据库,因此可以基于源码实现安装.基于源码安装有更多的灵活性.也就是说我们可以针对自己的硬件平台选用合适的编译器来优化编译后的二进制代码,根据不同的软件平台环境调整相关的编译参数,选择自身需要选择不同的安装组件,设定需要的字符集等等一些可以根据特定应用场景所作的各种调整.本文

Linux 源码编译安装 MySQL 5.5.x

Linux 环境:CentOS 6.5 MySQL 版本:5.5.20,附下载地址:[点击下载] 1.安装cmake MySQL从5.5版本开始,通过./configure进行编译配置方式已经被取消,取而代之的是cmake工具. 因此,我们首先要在系统中源码编译安装cmake工具. 下载 cmake [[email protected] soft]# wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz 解压 [[email protec

CentOS 7上源码编译安装和配置LNMP Web+phpMyAdmin服务器环境

什么是LNMP? LNMP(别名LEMP)是指由Linux, Nginx, MySQL/MariaDB, PHP/Perl/Python组合成的动态Web应用程序和服务器,它是一组Web应用程序的基础软件包,在这个基础环境上我们可以搭建任何使用PHP/Perl/Python等语言的动态网站,如商务网站.博客.论坛和开源Web应用程序软件等,它是互联网上被广泛使用的Web网站架构之一. 部署方式 从网站规模大小(访问流量.注册用户等)角度来看,LNMP架构可以使用单机部署方式和集群部署方式.单机部