linux下MySQL 5.6源码安装

linux下MySQL 5.6源码安装

1、下载:当前mysql版本到了5.6.20

http://dev.mysql.com/downloads/mysql

选择Source Code

2、必要软件包

yum -y install  gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake

3、编译安装

添加用户

groupadd mysql
useradd -r -g mysql mysql

编译安装

tar -zxvf mysql-5.6.20.tar.gz
cd mysql-5.6.20

#默认情况下是安装在/usr/local/mysql
cmake .
make && make install

编译参数

cmake  -DCMAKE_INSTALL_PREFIX=/alidata/server/mysql-5.6.20 -DMYSQL_DATADIR=/alidata/server/mysql-5.6.20/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/alidata/server/mysql-5.6.20/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci ;

编译的参数可以参考http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html

有时候会出现类似的问题。

-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://example.com:80
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- Configuring done
-- Generating done
  • 使用参数-DENABLE_DOWNLOADS=1 自动下载。
  • 有网络限制,设置http代理export http_proxy=http://example.com:80。环境变量http_proxy 也为 curl 等其他工具所用。尽管 yum 可以识别大写或小写的 http_proxy,但curl 要求环境变量的名称是小写。

  

  如果这个cmake这个步骤有出现问题,解决后重新再cmake一次。如果输出类似这样,那么就好了。

-- Running cmake version 2.6.4
-- MySQL 5.6.20
-- Packaging as: mysql-5.6.20-Linux-x86_64
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- Using cmake version 2.6.4
-- Not building NDB
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- Configuring done
-- Generating done
-- Build files have been written to: /root/tools/mysql-5.6.20

接着编译源码

make && make install

改变目录所有者

chown  mysql:mysql /alidata/server/mysql-5.6.20/

4、初始化数据库

cd /alidata/server/mysql-5.6.20/scripts
./mysql_install_db --user=mysql --basedir=/alidata/server/mysql-5.6.20 --datadir=/alidata/server/mysql-5.6.20/data

5、注册为服务

cd /alidata/server/mysql-5.6.20/support-files

#注册服务
cp mysql.server /etc/rc.d/init.d/mysql

#使用默认配置文件
cp ../my.cnf /etc/my.cnf

#修改配置文件
basedir=/alidata/server/mysql-5.6.20
datadir=/alidata/server/mysql-5.6.20/data

#让chkconfig管理mysql服务
chkconfig --add mysql

#开机启动
chkconfig mysql on

6、启动MySQL服务

service mysql start

7、改变编码,防止乱码

SHOW VARIABLES LIKE ‘character%‘

  

修改mysql的my.cnf文件

[client]
default-character-set=utf8

[mysqld]
character-set-server=utf8

[mysql]
default-character-set=utf8

8、将mysql的bin加入到path中

cd ~
#我把path添加到当前用户目录的bashrc中,如果需要全局设定,请修改`/etc/profile`
vi .bashrc

#加入以下内容
PATH=/alidata/server/mysql-5.6.20/bin:$PATH
export PATH

9、配置用户密码和远程访问权限

mysql -uroot
SET PASSWORD = PASSWORD(‘123456‘);

GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;

部分步骤debug 如下:

 ./mysql_install_db --user=mysql --basedir=/alidata/server/mysql-5.6.20 --datadir=/alidata/server/mysql-5.6.20/data
[[email protected] scripts]# ./mysql_install_db --user=mysql --basedir=/alidata/server/mysql-5.6.20 --datadir=/alidata/server/mysql-5.6.20/data
Installing MySQL system tables...2014-09-30 20:42:53 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-09-30 20:42:53 19761 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-09-30 20:42:53 19761 [Note] InnoDB: The InnoDB memory heap is disabled
2014-09-30 20:42:53 19761 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-09-30 20:42:53 19761 [Note] InnoDB: Memory barrier is not used
2014-09-30 20:42:53 19761 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-09-30 20:42:53 19761 [Note] InnoDB: Using CPU crc32 instructions
2014-09-30 20:42:53 19761 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-09-30 20:42:53 19761 [Note] InnoDB: Completed initialization of buffer pool
2014-09-30 20:42:53 19761 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-09-30 20:42:53 19761 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2014-09-30 20:42:53 19761 [Note] InnoDB: Database physically writes the file full: wait...
2014-09-30 20:42:53 19761 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-09-30 20:42:54 19761 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-09-30 20:42:55 19761 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-09-30 20:42:55 19761 [Warning] InnoDB: New log files created, LSN=45781
2014-09-30 20:42:55 19761 [Note] InnoDB: Doublewrite buffer not found: creating new
2014-09-30 20:42:55 19761 [Note] InnoDB: Doublewrite buffer created
2014-09-30 20:42:55 19761 [Note] InnoDB: 128 rollback segment(s) are active.
2014-09-30 20:42:55 19761 [Warning] InnoDB: Creating foreign key constraint system tables.
2014-09-30 20:42:55 19761 [Note] InnoDB: Foreign key constraint system tables created
2014-09-30 20:42:55 19761 [Note] InnoDB: Creating tablespace and datafile system tables.
2014-09-30 20:42:55 19761 [Note] InnoDB: Tablespace and datafile system tables created.
2014-09-30 20:42:55 19761 [Note] InnoDB: Waiting for purge to start
2014-09-30 20:42:55 19761 [Note] InnoDB: 5.6.20 started; log sequence number 0
2014-09-30 20:42:56 19761 [Note] Binlog end
2014-09-30 20:42:56 19761 [Note] InnoDB: FTS optimize thread exiting.
2014-09-30 20:42:56 19761 [Note] InnoDB: Starting shutdown...
2014-09-30 20:42:57 19761 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2014-09-30 20:42:57 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-09-30 20:42:57 19783 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-09-30 20:42:57 19783 [Note] InnoDB: The InnoDB memory heap is disabled
2014-09-30 20:42:57 19783 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-09-30 20:42:57 19783 [Note] InnoDB: Memory barrier is not used
2014-09-30 20:42:57 19783 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-09-30 20:42:57 19783 [Note] InnoDB: Using CPU crc32 instructions
2014-09-30 20:42:57 19783 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-09-30 20:42:57 19783 [Note] InnoDB: Completed initialization of buffer pool
2014-09-30 20:42:57 19783 [Note] InnoDB: Highest supported file format is Barracuda.
2014-09-30 20:42:57 19783 [Note] InnoDB: 128 rollback segment(s) are active.
2014-09-30 20:42:57 19783 [Note] InnoDB: Waiting for purge to start
2014-09-30 20:42:57 19783 [Note] InnoDB: 5.6.20 started; log sequence number 1625977
2014-09-30 20:42:57 19783 [Note] Binlog end
2014-09-30 20:42:57 19783 [Note] InnoDB: FTS optimize thread exiting.
2014-09-30 20:42:57 19783 [Note] InnoDB: Starting shutdown...
2014-09-30 20:42:58 19783 [Note] InnoDB: Shutdown completed; log sequence number 1625987
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:

  /alidata/server/mysql-5.6.20/bin/mysqladmin -u root password ‘new-password‘
  /alidata/server/mysql-5.6.20/bin/mysqladmin -u root -h iZ23lt92evyZ password ‘new-password‘

Alternatively you can run:

  /alidata/server/mysql-5.6.20/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 . ; /alidata/server/mysql-5.6.20/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

New default config file was created as /alidata/server/mysql-5.6.20/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

参考: 
http://blog.163.com/[email protected]/blog/static/815232582013885310900/ 
http://www.cnblogs.com/xiongpq/p/3384681.html

转自:  http://my.oschina.net/looly/blog/297980#OSC_h2_1

时间: 2024-10-19 09:46:49

linux下MySQL 5.6源码安装的相关文章

linux下使用qq————pidgin-lwqq 源码安装详细教程

今天费了不少功夫终于安装了pidgin——lwqq,可以在linux上使用qq了lwqq是在linux下通讯工具pidgin上使之支持webqq协议的组件下面来详细介绍一下安装方法,共介绍两种,通过apt-get工具和通过源码安装(针对ubuntu和debian用户) 要安装pidgin-lwqq首先要安装lwqq,这两个组件已经被分开 首先我们来安装lwqq 先是lwqq依赖的库的安装使用apt-get命令可以 $ sudo apt-get install build-essential cm

linux下PostgreSQL数据库的源码安装

实验环境>>>>>>>>>>>>>>>>>>操作系统:CentOS release 6.3 (Final)数据库版本:PostgreSQL 9.3.5 安装postgresql的依赖有 a.需要一个ISO/ANSIC编译器(至少兼容C89). b.需要GNU make: 不能使用其它make程序. c.缺省时将自动使用GNU Readline库.需要readline和readline-devel 两

CentOS 6.3下MySQL 5.6源码安装

Linux操作系统:CentOS 6.3 1:下载:当前mysql版本到了5.6.10 下载地址:http://dev.mysql.com/downloads/mysql/5.6.html#downloads 选择“Source Code”  在此之前最好注册一个Oracle账号 2:必要软件包 yum -y install  gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* li

linux服务之Lamp的源码安装(centos)

Linux+Apache+Mysql+Php源码安装 一.安装环境: 系统:Centos6.5x64 Apache: httpd-2.4.10.tar.gz Mysql: mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz Php: php-5.6.0.tar.gz Apr: apr-1.5.1.tar.gz Apr-util: apr-util-1.5.3.tar.gz Libxml2: libxml2-2.9.1.tar.gz 默认安装路径我们统一安装到/us

Linux中centos中httpd源码安装过程详解

在Linux中软件安装有两大类,一类是软件包安装,一类是源代码安装.软件包安装就是指将编译好的二进制封装成rpm包,可以直接使用rpm工具和yum工具安装.源代码安装是指没有编译成二进制,需要通过手动编译的.使用源代码安装的原因有两个,一个就是想使用最新版的软件,另一类就是想自定义其功能的. 在httpd的源码安装过程中需要用到:APR.APR-UTIL. PCRE.httpd源码安装过程:1.展开压缩文件,把压缩文件解压缩到/usr/local/src.2.在解压文件目录使用 ./config

mysql学习之--源码安装(1)

0x01 MySQL 从 5.5 版本开始,通过 ./configure 进行编译配置方式已经被取消,取而代之的是 cmake 工具 引用一句话 cmake的重要特性之一是其独立于源码(out-of-source)的编译功能,即编译工作可以在另一个指定的目录中而非源码目录中进行,这可以保证源码目录不受任何一次编译的影响,因此在同一个源码树上可以进行多次不同的编译,如针对于不同平台编译. 所以首先要安装cmake 可以源码安装也可以 使用已经编译好的rpm包进行安装 yum安装  yum inst

linux程序包管理与源码安装

一.RPM包简介: linux之所以那么强大,除了linux强大的内核,还有很大一部分取决于linux的软件包,假想没有软件包,就一个内核在运行,人类需要和内核打交道是多么痛苦,但是聪明的人类发明了bash,通过bash,人就可以使用高级语言,和机器沟通,这其中的bash起始也是一个软件包,当然linux除了bash还有各式各样的包,帮助我们完成各种任务,这其中便涉及到程序的包管理. rpm包管理器(原名redhat package manager,后成为行业标准,命名为rpm package

在ubuntu下,进行php7源码安装

作为一名php的攻城师,如果没有玩php源码安装是说不过去的.我们知道php之所以这么流行,跟它的开源文化和lamp配套有很大关系.由于PHP7废弃了很多功能,所以一些依赖这些功能的程序可能无法运行,尝鲜前请三思.比如很多国产软件都在依赖的mysql相关函数,如果自己开发php应用请用mysqli代替.不过WordPress是没有问题的,尽情使用吧. 下面进入正题,第一步,当然是下载源码和解压 $ cd ~ $ wget http://cn2.php.net/distributions/php-

Linux软件管理之src源码安装编译

在很多时候我们需要自定义软件的特性,这时就需要用到源码安装.那么,网上有很多编译源码的工具,那么,我们怎么知道别人使用的是什么工具呢.其实我也不知道(*^▽^*). 那么本篇博客主要是写C代码的源码安装. 什么都不说,直接先上来总结源码安装的四步骤: 第一步:./configure:    [当然,我们在这步骤之前还必须解压源码包]     (1) 通过选项传递参数,指定启用特性.安装路径等:执行时会参考用户的指定以及Makefile.in文件生成makefile     (2) 检查依赖到的外