Centos 7 源码编译安装mysql 5.6.22(整理篇)

经过看了几篇文档,都没有写完全。稍微整理了一下,重新一步一步进行编译安装mysql在centos7上。

安装步骤如下:

1、安装编译环境


# yum -y install gcc- gcc-c++  ncurses-devel per

# yum install cmake

2、建立mysql目录和帐号,及目录属性


# mkdir -p /data/mydata

# mkdir -p /usr/local/mysql

# useradd -d /data/mydata -s  /sbin/nologin -g mysql mysql

# cd data/mydata/

# chown -R mysql:mysql .

# cd /usr/local/mysql/

# chown -R mysql:mysql .

3、下载copy到系统里


# cd

# ls

anaconda-ks.cfg  mysql-5.6.22.tar.gz

4、解压mysql源码包


# tar -zxvf mysql-5.6.22.tar.g

5、编译mysql源码包

说明:从mysql5.5起,mysql源码安装开始使用cmake了,设置源码编译配置脚本。


-DCMAKE_INSTALL_PREFIX=dir_name


设置mysql安装目录


-DMYSQL_UNIX_ADDR=file_name


设置监听套接字路径,这必须是一个绝对路径名。默认为/tmp/mysql.sock


-DDEFAULT_CHARSET=charset_name


设置服务器的字符集。
 缺省情况下,MySQL使用latin1的(CP1252西欧)字符集。cmake/character_setsNaNake文件包含允许的字符集名称列表。


-DDEFAULT_COLLATION=collation_name


设置服务器的排序规则。


-DWITH_INNOBASE_STORAGE_ENGINE=1 
 -DWITH_ARCHIVE_STORAGE_ENGINE=1
 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 
 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1


存储引擎选项:
 
 MyISAM,MERGE,MEMORY,和CSV引擎是默认编译到服务器中,并不需要明确地安装。
 
 静态编译一个存储引擎到服务器,使用-DWITH_engine_STORAGE_ENGINE= 1
 
 可用的存储引擎值有:ARCHIVE, BLACKHOLE, EXAMPLE, FEDERATED, INNOBASE (InnoDB),  PARTITION (partitioning support), 和PERFSCHEMA  (Performance Schema)


-DMYSQL_DATADIR=dir_name


设置mysql数据库文件目录


-DMYSQL_TCP_PORT=port_num


设置mysql服务器监听端口,默认为3306


-DENABLE_DOWNLOADS=bool


是否要下载可选的文件。例如,启用此选项(设置为1),cmake将下载谷歌所使用的测试套件运行单元测试。


# cd mysql-5.6.22

# cmake  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=mysql.mysql  -DDEFAULT_CHARSET=gbk -DDEFAULT_COLLATION=gbk_chinese_ci -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWIT

H_ARCHIVE_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mydata  -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1

[[email protected] mysql-5.6.22]# make

[[email protected] mysql-5.6.22]# make  install

6、初始化mysql数据库


# cd scripts/

# ls

mysql_install_db

# ./mysql_install_db --user=mysql  --datadir=/data/mydata

FATAL ERROR: please install the following  Perl modules before executing ./mysql_install_db:

Data::Dumper

初始化过程中会报错,需要安装perl-Module-Install.noarch

# yum install -y  perl-Module-Install.noarch

# scripts/mysql_install_db --user=mysql  --datadir=/data/mydata

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:

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

./bin/mysqladmin -u root -h localhost.localdomain password  ‘new-password‘

Alternatively you can run:

./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 . ; ./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  ./my.cnf and

will be used by default by the server  when you start it.

You may edit this file to change server  settings

7、复制mysql服务和启动文件


# cp  /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

# cp  /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

8、开启mysqld服务


[[email protected] ~]# service mysqld start

Starting MySQL. SUCCESS!

9、添加到chkconfig里


[[email protected] ~]# chkconfig

[[email protected] ~]# chkconfig --add  mysqld

[[email protected] ~]# chkconfig --list

iprdump           0:off 1:off 2:on 3:on 4:on 5:on 6:off

iprinit                0:off 1:off 2:on 3:on 4:on 5:on 6:off

iprupdate           0:off 1:off 2:on 3:on 4:on 5:on 6:off

mysqld            0:off 1:off 2:on 3:on 4:on 5:on 6:off

netconsole          0:off 1:off 2:off 3:off 4:off 5:off 6:off

network           0:off 1:off 2:on 3:on 4:on 5:on 6:off

检查端口

[[email protected] ~]# netstat -tulnp | grep  3306

tcp6        0      0 :::3306                 :::*                    LISTEN

21466/mysqld

10、设置环境变量PATH路径


[[email protected] /]# vi /etc/profile

-- INSERT --

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

export PATH

:wq

"/etc/profile"

# source /etc/profile

11、进入数据库报错


[[email protected] /]# mysql -uroot

ERROR 2002 (HY000): Can‘t connect to  local MySQL server through socket ‘mysql.mysql‘ (2)

12、编辑my.cnf


[[email protected] ~]# vi /etc/my.cnf

[mysqld]

basedir=/usr/local/mysql

datadir=/data/mydata

port=3306

socket=/data/mydata/mysql.sock

server_id=1

[mysqld_safe]

log-error=/data/log/mysqld.log

[mysql]

socket=/data/mydata/mysql.sock

[mysqldump]

socket=/data/mydata/mysql.sock

[mysqladmin]

socket=/data/mydata/mysql.sock

13、重启mysqld服务


# etc/init.d/mysqld restart

14、进入数据库并设置密码


# mysql –uroot

mysql> set password = password(‘123456‘);

Query OK, 0 rows affected (0.00 sec)

mysql> quit

Bye

到这里数据库安装就完成了

感谢各位大拿的blog。参考链接

http://www.aiezu.com/db/mysql_cant_connect_through_socket.html

http://blog.csdn.net/xiagege3/article/details/41852895

http://blog.csdn.net/hengrjgc/article/details/40299213

http://wilr.iteye.com/blog/2168659

http://www.cnblogs.com/xiongpq/p/3384681.html

http://msnvip.iteye.com/blog/542004

http://blog.sina.com.cn/s/blog_637e04c9010117ri.html

http://www.cnblogs.com/fuhj02/p/3541173.html

时间: 2024-10-09 20:25:03

Centos 7 源码编译安装mysql 5.6.22(整理篇)的相关文章

CentOS 7 源码编译安装MySQL 5.7.14

一.添加用户和组 1. 进入root: su 2. 添加组: groupadd mysql 3. 添加用户: useradd -r -g mysql -s /bin/false mysql 二.安装 1. 首先到MySQL官网下载最新版的MySQL 5.7.14,进入http://dev.mysql.com/downloads/mysql/,选择Source Code下的Generic Linux. 2. 解压 tar zxvf mysql-5.7.14.tar.gz 3. 安装MySQL所需要

CentOS 7 源码编译安装 Mysql 5.7

1.创建 mysql 用户,用户组,以及相关目录 /usr/sbin/groupadd mysql /usr/sbin/useradd -g mysql mysql mkdir -p /opt/local/mysql/data mkdir -p /opt/local/mysql/binlog mkdir -p  /opt/local/mysql/logs mkdir -p /opt/local/mysql/relaylog mkdir -p /var/lib/mysql mkdir -p /op

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.

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

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.5源码编译安装MySQL 5.6

对于服务器的环境,个人觉得还是源码编译安装的非常靠谱,假如有服务器要变更,直接rm掉安装目录即可.有些人喜欢yum安装,但是在卸载yum remove的时候,一不小心,就卸载了一个基础库,导致系统的shell命令失效,情节严重的可能连系统启动都会存在问题. 1. 安装系统的一些必要基础库 yum -y install  gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtoo

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

源码编译安装 MySQL 5.5.x 实践(转)

1.安装cmakeMySQL从5.5版本开始,通过./configure进行编译配置方式已经被取消,取而代之的是cmake工具.因此,我们首先要在系统中源码编译安装cmake工具. # wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz # tar zxvf cmake-2.8.4.tar.gz # cd cmake-2.8.4 # ./configure# make# make install 2.确保以下所需系统软件包已经被安装通过

源码编译安装 MySQL 5.5.x 实践

1.安装cmakeMySQL从5.5版本开始,通过./configure进行编译配置方式已经被取消,取而代之的是cmake工具.因此,我们首先要在系统中源码编译安装cmake工具. # wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz # tar zxvf cmake-2.8.4.tar.gz # cd cmake-2.8.4 # ./configure# make# make install 2.确保以下所需系统软件包已经被安装通过