一、MySQL数据库的官方网址:

  • https://www.oracle.com/
  • http://dev.mysql.com/doc/refman/5.7/en/linux-installation.html
  •      
     //不同版本的安装文档和下载可以在这里找

Centos6源码部署MySQL5.6

mysql从5.5版本开始,不再使用./configure编译,而是使用cmake编译器

mysql-5.6.16.tar.gz源码包下载地址:

我的mysql目录配置如下:
安装路径:/usr/local/mysql
数据库路径:/data/mysql
源码包存放位置:/usr/software

准备工作:安装基本依赖包,先用yum安装cmake、automake 、autoconf
,另MySQL 5.6.x需要最少安装的包有:bison,gcc、gcc-c++、ncurses-devel
[[email protected]
~]# yum install cmake make -y
[[email protected]
~]# yum install gcc gcc-c++ autoconf bison automake zlib* fiex*
libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* -y
[[email protected]
~]# cp /root/mysql-5.6.15.tar.gz /usr/software/
[[email protected]
~]# cd /usr/software
开始编译安装
[[email protected]
~]# tar -zxvf mysql-5.6.15.tar.gz
[[email protected]
~]# cd mysql-5.6.15
[[email protected]
~]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql/ \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
[[email protected]
~]# make && make install

mysql官网英文文档简单翻译说明一下
The MyISAM, MERGE, MEMORY, and CSV engines are mandatory (always
compiled into the server) and need not be installed
explicitly.(说明:mysql默认支持的数据库引擎有MyISAM, MERGE, MEMORY,
CSV,无需在编译时再声明)
所以上面的编译条件省掉了如下两行
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
但INNODB一定要声明式安装,所以多了这一行
-DWITH_INNOBASE_STORAGE_ENGINE=1 \

查看mysql.mysql的用户及组是否存在

[[email protected]
~]# cat /etc/passwd |grep mysql

mysql:x:501:503::/home/mysql:/bin/bash

[[email protected]
~]# cat /etc/group |grep mysql

mysql:x:503:

不OK就执行以下两行命令(否则跳过这一步)
[[email protected]
~]# groupadd mysql #添加mysql用户组
[[email protected]
~]# useradd mysql -g mysql -s /sbin/nologin # 添加mysql用户

以下带红色字体的命令非常非常,必须要执行
[[email protected]
~]# cd /usr/local/mysql
[[email protected]
~]# chown mysql.mysql -R . #将mysql目录赋予mysql用户的执行权限
[[email protected]
~]# chown mysql.mysql -R /data/mysql
[[email protected]
~]# cp support-files/my-default.cnf /etc/my.cnf #mysql配置文件
[[email protected]
~]# chmod 755 scripts/mysql_install_db
#赋予mysql_install_db执行权限

以下命令为mysql 启动及自启动配置
[[email protected]
~]# scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql
–datadir=/data/mysql/

输出如下信息:

2013-12-12 13:58:23 25913 [Note] InnoDB: The InnoDB memory heap is
disabled

2013-12-12 13:58:23 25913 [Note] InnoDB: Mutexes and rw_locks use GCC
atomic builtins

2013-12-12 13:58:23 25913 [Note] InnoDB: Compressed tables use zlib
1.2.3

2013-12-12 13:58:23 25913 [Note] InnoDB: Using Linux native AIO

2013-12-12 13:58:23 25913 [Note] InnoDB: Not using CPU crc32
instructions

2013-12-12 13:58:23 25913 [Note] InnoDB: Initializing buffer pool,
size = 128.0M

2013-12-12 13:58:23 25913 [Note] InnoDB: Completed initialization of
buffer pool

2013-12-12 13:58:23 25913 [Note] InnoDB: The first specified data file
./ibdata1 did not exist: a new database to be created!

2013-12-12 13:58:23 25913 [Note] InnoDB: Setting file ./ibdata1 size
to 12 MB

2013-12-12 13:58:23 25913 [Note] InnoDB: Database physically writes
the file full: wait…

2013-12-12 13:58:23 25913 [Note] InnoDB: Setting log file
./ib_logfile101 size to 48 MB

2013-12-12 13:58:24 25913 [Note] InnoDB: Setting log file
./ib_logfile1 size to 48 MB

2013-12-12 13:58:24 25913 [Note] InnoDB: Renaming log file
./ib_logfile101 to ./ib_logfile0

2013-12-12 13:58:24 25913 [Warning] InnoDB: New log files created,
LSN=45781

2013-12-12 13:58:24 25913 [Note] InnoDB: Doublewrite buffer not found:
creating new

2013-12-12 13:58:24 25913 [Note] InnoDB: Doublewrite buffer created

2013-12-12 13:58:24 25913 [Note] InnoDB: 128 rollback segment(s) are
active.

2013-12-12 13:58:24 25913 [Warning] InnoDB: Creating foreign key
constraint system tables.

2013-12-12 13:58:24 25913 [Note] InnoDB: Foreign key constraint system
tables created

2013-12-12 13:58:24 25913 [Note] InnoDB: Creating tablespace and
datafile system tables.

2013-12-12 13:58:24 25913 [Note] InnoDB: Tablespace and datafile
system tables created.

2013-12-12 13:58:24 25913 [Note] InnoDB: Waiting for purge to start

2013-12-12 13:58:24 25913 [Note] InnoDB: 5.6.15 started; log sequence
number 0

2013-12-12 13:58:26 25913 [Note] Binlog end

2013-12-12 13:58:26 25913 [Note] InnoDB: FTS optimize thread exiting.

2013-12-12 13:58:26 25913 [Note] InnoDB: Starting shutdown…

2013-12-12 13:58:27 25913 [Note] InnoDB: Shutdown completed; log
sequence number 1625977

OK

 

Filling help tables…2013-12-12 13:58:27 0 [Warning] TIMESTAMP with
implicit DEFAULT value is deprecated. Please use
–explicit_defaults_for_timestamp server option (see documentation
for more details).

2013-12-12 13:58:27 25936 [Note] InnoDB: The InnoDB memory heap is
disabled

2013-12-12 13:58:27 25936 [Note] InnoDB: Mutexes and rw_locks use GCC
atomic builtins

2013-12-12 13:58:27 25936 [Note] InnoDB: Compressed tables use zlib
1.2.3

2013-12-12 13:58:27 25936 [Note] InnoDB: Using Linux native AIO

2013-12-12 13:58:27 25936 [Note] InnoDB: Not using CPU crc32
instructions

2013-12-12 13:58:27 25936 [Note] InnoDB: Initializing buffer pool,
size = 128.0M

2013-12-12 13:58:27 25936 [Note] InnoDB: Completed initialization of
buffer pool

2013-12-12 13:58:27 25936 [Note] InnoDB: Highest supported file format
is Barracuda.

2013-12-12 13:58:27 25936 [Note] InnoDB: 128 rollback segment(s) are
active.

2013-12-12 13:58:27 25936 [Note] InnoDB: Waiting for purge to start

2013-12-12 13:58:27 25936 [Note] InnoDB: 5.6.15 started; log sequence
number 1625977

2013-12-12 13:58:27 25936 [Note] Binlog end

2013-12-12 13:58:27 25936 [Note] InnoDB: FTS optimize thread exiting.

2013-12-12 13:58:27 25936 [Note] InnoDB: Starting shutdown…

2013-12-12 13:58:29 25936 [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:

 

/usr/local/mysql/bin/mysqladmin -u root password ‘new-password’

/usr/local/mysql/bin/mysqladmin -u root -h ziteng26 password
‘new-password’

 

Alternatively you can run:

 

/usr/local/mysql/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/mysql/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 with the ./bin/mysqlbug script!

 

The latest information about MySQL is available on the web at

 

 

Support MySQL by buying support/licenses at

 

New default config file was created as /usr/local/mysql/my.cnf and

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

You may edit this file to change server settings

 

WARNING: Default config file /etc/my.cnf exists on the system

This file will be read by default by the MySQL server

If you do not want to use this, either remove it, or use the

 

–defaults-file argument to mysqld_safe when starting the server

 

[[email protected]
~]# cp support-files/mysql.server /etc/init.d/mysqld
[[email protected]
~]# chmod 755 /etc/init.d/mysqld
查看mysqld服务是否设置为开机启动
[[email protected]
~]# chkconfig –list|grep mysqld
设置为开机启动
[[email protected]
~]# chkconfig mysqld on

启动mysql数据库,会输出一系列有用的信息,告诉你接下去如何初始化mysql

[[email protected]
mysql]# service mysqld start

按照上述英文,我们来初始化管理员root的密码

[[email protected]
~]# /usr/local/mysql/bin/mysqladmin -u root password ‘yourpassword’

此处yourpassword设置为 manager

 

 

众所周知,mysql有两种帐号类型,即localhost和%,前者限本机连接mysql,后者可用于其它机器远程连接mysql

最后,处理帐号登录问题,让root帐号密码可以本地和远程连接使用

[[email protected]
~]# /usr/local/mysql/bin/mysql -u root -p
#敲入该命令后,屏幕会提示输入密码,输入上一步设置的yourpassword

删除root密码为空的记录

mysql> use mysql;

mysql> delete from user where password=”;

mysql> flush privileges;

配置mysql允许root远程登录 #登录

mysql> grant all privileges on *.* to
[email protected]’%’
identified by “manager”;

mysql> flush privileges;

mysql> select User,Password,Host from user;

 

上述命令如果执行成功

 

mysql> quit

 

 

至此,mysql安装已经全部结束.

 

mysql从5.5版本开始,不再使用./configure编译,而是使用cmake编译器
mysql-5.6.16.tar.gz源码包下载地址: …

Centos6.0 64位MySQL 5.6.11 CMake安装部署

普及:

Docker 容器构建

  • 使用Dockerfile构建镜像
  • 使用官方提供的Docker镜像

二、MySQL的安装方法:

以下是MySQL常见的三种安装方式:

  • 二进制  rpm   Yum Repository   
    mysql57-community-release-el7-9.noarch.rpm
  • 二进制  预编译  Generic                       
    mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
  • 源码包安             Source Code              
     
    mysql-5.7.19.tar.gz

 

关系型数据库:
Oracle、MySQL、PostgreSQL

所谓Dockerfile

Dockerfile是一种被Docker程序解释的脚本,Dockerfile由一条一条的指令组成,每条指令对应Linux下面的一条命令。Docker程序将这些Dockerfile指令翻译真正的Linux命令。Dockerfile有自己书写格式和支持的命令,Docker程序解决这些命令间的依赖关系,类似于Makefile。Docker程序将读取Dockerfile,根据指令生成定制的image。相比image这种黑盒子,Dockerfile这种显而易见的脚本更容易被使用者接受,它明确的表明image是怎么产生的。有了Dockerfile,当我们需要定制自己额外的需求时,只需在Dockerfile上添加或者修改指令,重新生成image即可,省去了敲命令的麻烦。

不过这里只介绍Dockerfile构建容器的步骤,接下来的文章都是以第二种方式,
使用官方提供的Docker镜像来部署

三、Yum的方法安装MySQL:

  • yum安装mysql 5.7
    的官方安装方法地址

1、下载安装包

  • *此地址为Mysql 8.0 的安装源其中包含MySQL
    5.7的源,可以在后边步骤修改开放的仓库:
     *

2、 设置安装初始环境

暂时先把防火墙关闭保证实验顺利:
[root@host-131 ~]# systemctl stop firewalld 
[root@host-131 ~]# systemctl disable firewalld.service
临时关闭SELlinux:
[root@host-131 ~]# setenforce 0
永久关闭SELinux:
[root@host-131 ~]# sed -ri '/^SELINUX=/c\SELINUX=disabled' /etc/selinux/config
查看SELinux状态:
[root@host-131 ~]# getenforce
Disabled

 3、卸载系统自带的数据库(Centos7自带的是maridb)

一、下载所需软件

非关系型数据库(NOSQL):
HBase、Redis

下载MySQL官方提供的Docker镜像

$ docker pull mysql:tag

:tag 是你想从官方拉取的版本(例如5.5, 5.6, 5.7 或者latest )。如果省略
tag 则拉取当前最新的版本, 即latest。

可以使用以下的命令列出下载Docker镜像:

$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mysql               5.7                 dd0afb9bc4a9        3 days ago          408MB
mysql               latest              dd0afb9bc4a9        3 days ago          408MB

可参考:【MySQL解惑笔记】Centos7下卸载彻底MySQL数据库

卸载maridb:
[root@host-131 ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
[root@host-131 ~]# yum -y remove mari*
[root@host-131 ~]# rm -rf /var/lib/mysql/*
[root@host-131 ~]# rpm -qa | grep mariadb
[root@host-131 ~]# 

4、修改仓库

[root@host-131 src]# yum rpolist all |grep mysql      //查看所有仓库,并能够看到开启和禁用的仓库
[root@host-131 src]# yum repolist enabled | grep "mysql.*-community.*"  //查看所有开启的仓库,发现现在开启的是MySQL 8.0的,我们需要开启MySQL5.7的仓库
mysql-connectors-community/x86_64 MySQL Connectors Community                  51
mysql-tools-community/x86_64      MySQL Tools Community                       63
mysql80-community/x86_64          MySQL 8.0 Community Server                  17     //k

 开启和关闭不同仓库,官方提供了三种修改方法:

方法一:
shell> sudo yum-config-manager --disable mysql80-community
shell> sudo yum-config-manager --enable mysql57-community

方法二:
shell> sudo dnf config-manager --disable mysql57-community
shell> sudo dnf config-manager --enable mysql56-community

方法三:
我们直接修改Yum源文件:
[root@host-131 ~]# cd /etc/yum.repos.d 
[root@host-131 yum.repos.d]# vim mysql-community.repo 
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=1                        //修改为1表示开启
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=0                        //修改为0表示关闭
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[root@host-131 yum.repos.d]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community                  51
mysql-tools-community/x86_64      MySQL Tools Community                       63
mysql57-community/x86_64          MySQL 5.7 Community Server                 267    //可以看到5.7存储仓库已经开启

注意:我们应该在任何时候只启用一个发布系列的子存储库。当启用多个发布系列的子存储库时,Yum将使用最新的系列。
通过运行以下命令并检查其输出(对于Fedora,用dnf替换yum),验证是否启用了正确的子库并禁用了它:
[root@host-131 yum.repos.d]# yum repolist enabled | grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community                  51
mysql-tools-community/x86_64      MySQL Tools Community                       63
mysql57-community/x86_64          MySQL 5.7 Community Server                 267

 5、安装MySQL数据库

[root@host-131 yum.repos.d]# yum -y install mysql-community-server
[root@host-131 ~]# systemctl start mysqld   
[root@host-131 ~]# systemctl enable mysqld   设置开机自启动
[root@host-131 ~]# systemctl status mysqld  查看mysql启动状态

[root@host-131 ~]# ls /var/lib/mysql    (安装后可以看到初始化的数据库)
auto.cnf    client-cert.pem  ibdata1      ibtmp1      mysql.sock.lock     public_key.pem   sys
ca-key.pem  client-key.pem   ib_logfile0  mysql   performance_schema  server-cert.pem
ca.pem      ib_buffer_pool   ib_logfile1  mysql.sock  private_key.pem     server-key.pem

6、首次登录数据库,并设置初始化密码

[root@host-131 ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
发现是禁止访问的

在服务器的初始启动时,由于服务器的数据目录为空:服务器初始化。SSL证书和密钥文件是在数据目录中生成的。
安装并启用了validate_password。
一个超级用户帐户'root'@'localhost被创建。
超级用户的密码被设置并存储在错误日志文件中。要显示它,请使用以下命令:

MySQL5.5之前版本安装后可以直接登录
MySQL5.5自动生成的密码是空的
MySQL5.6是将密码放在root下的
MySQL5.7是将密码放在:
[root@host-131 ~]# grep 'temporary password' /var/log/mysqld.log
2018-05-30T06:34:56.956716Z 1 [Note] A temporary password is generated for root@localhost: xt8S3rWXOL/C
[root@host-131 ~]# 
[root@host-131 ~]# mysql -uroot -p"xt8S3rWXOL/C"
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.22
修改密码:
方法一:
[root@host-131 ~]# mysqladmin -uroot -p"xt8S3rWXOL/C" password "Yanglt123."   //密码要满足复杂性要求
[root@host-131 ~]# mysql -uroot -p"Yanglt123."

方法二:

[root@host-131 ~]# grep 'temporary password' /var/log/mysqld.log
2018-05-30T06:34:56.956716Z 1 [Note] A temporary password is generated for root@localhost: xt8S3rWXOL/C
[root@host-131 ~]# 
[root@host-131 ~]# mysql -uroot -p"xt8S3rWXOL/C"

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

 到此数据库安装成功:

源码安装可参考文章:*【Linux运维】LNMP环境配置*

  

linux用 wget 下载需要的软件,保存到目录 /usr/local/src 下

图形数据库:
Titan

启动MySQL服务器

$ docker run --name=mysql -e MYSQL_ROOT_PASSWORD=root -v /app/mysql:/var/lib/mysql -d mysql

--name=mysql 这个属性是为启动的MySQL容器设置一个别名

-d 以守护进程方式运行 (后台运行)

-e MYSQL_ROOT_PASSWORD在启动MySQL的时候设置密码,这里密码以root演示

-v /app/mysql/:/var/lib/mysql 通过Volume把容器内的文件映射到物理机

wget
ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.6/mysql-5.6.11.tar.gz

时序数据库:
influxdb

查看MySQL的日志

$ docker logs mysql

wget

一、MySQL(mysql)

二进制,默认放到/usr/local下

连接MySQL服务器

$ docker exec -it mysql mysql -u root -p

提示输入密码的时候,输入刚刚创建的时候指定的密码就ok了。现在你就能随意使用的MySQL服务器咯。

修改
MySQL密码:$ ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';

mysql
最新的版本都需要cmake编译安装,估计以后的版本也会采用这种方式,所以特地记录一下安装步骤及过程,以供参考。

安装MySQL步骤:

容器管理

$ docker restart mysql
$ docker stop mysql
$ docker start mysql
$ docker rm mysql

注意,当你想要使用docker rm mysql 之前,请记得先停止容器(docker stop
mysql)的运行。

 

1.从本地选择mysql的安装包上传到Linux上
rz

注意:此安装是默认centos下已经安装了最新工具包,比如GNU make, GCC, Perl,
ncurses(其它版本linux安装libncurses5-dev),如果在编译安装过程中发现有缺失的工具包,先yum
install 单独下载安装再继续即可。

2.查看是否安
# ps -ef | grep mysql

 

3.查看是否由RPM安装包
# rpm -qa | grep mysql

以下安装中涉及的几点需要提前说明的问题:

4.移动安装包到/usr/local下
# cp xxx  /usr/local/
  1. 所有下载的文件将保存在 /usr/local/src/ 目录下

  2. mysql 将以mysql用户运行,而且将加入 service 开机自动运行

  3. mysql 将被安装在 /usr/local/mysql/ 目录下

  4. mysql 默认安装使用 utf8 字符集

  5. mysql 的数据和日志文件保存在 /usr/local/mysql/ 对应目录下

  6. mysql 的配置文件保存于/etc//my.cnf

5.解压
# tar -zxvf mysql安装包

 

6.重命名文件夹
# mv 解压之后的mysql文件名 mysql

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

7.创建一个dba组
# groupadd -g 101 dba
    101:该组的id

 

8.创建一个用户
# useradd -u 514 -g dba -G root -d /usr/local/mysql mysqladmin
    514:指定该用户名字
    -g xxx:表示组名是xxx
    -G xxx:拥有root
    -d:指定用户路径

生产环境:给你的用户肯定不是root,给xxxx/xxx(sudo/不带sudo)

==sudo==:创建一个mysql服务的管理的用户
不 sudo:IT给你的用户开启sudo权限

为什么要创建mysqladmin/dba?

1.一个用户只对一个组件
2.dba组

yum –y install vim

9.可以创建密码
    # passwd mysqladmin

yum –y install gcc

10.如果没有.bash_profile文件,就拷贝
    # cp /etc/skel/.* /usr/local/mysql

yum –y install gcc-c++

11.重新覆盖/etc/my.cnf
    # vi /etc/my.cnf
    先按dG删除全部,然后粘贴以下内容
        [client]
        port            = 3306
        socket          = /usr/local/mysql/data/mysql.sock

        [mysqld]
        port            = 3306
        socket          = /usr/local/mysql/data/mysql.sock

        skip-external-locking
        key_buffer_size = 256M
        sort_buffer_size = 2M
        read_buffer_size = 2M
        read_rnd_buffer_size = 4M
        query_cache_size= 32M
        max_allowed_packet = 16M
        myisam_sort_buffer_size=128M
        tmp_table_size=32M

        table_open_cache = 512
        thread_cache_size = 8
        wait_timeout = 86400
        interactive_timeout = 86400
        max_connections = 600

        # Try number of CPU's*2 for thread_concurrency
        thread_concurrency = 32

        #isolation level and default engine 
        default-storage-engine = INNODB
        transaction-isolation = READ-COMMITTED

        server-id  = 1
        basedir     = /usr/local/mysql
        datadir     = /usr/local/mysql/data
        pid-file     = /usr/local/mysql/data/hostname.pid

        #open performance schema
        log-warnings
        sysdate-is-now

        binlog_format = MIXED
        log_bin_trust_function_creators=1
        log-error  = /usr/local/mysql/data/hostname.err
        log-bin=/usr/local/mysql/arch/mysql-bin
        #other logs
        #general_log =1
        #general_log_file  = /usr/local/mysql/data/general_log.err
        #slow_query_log=1
        #slow_query_log_file=/usr/local/mysql/data/slow_log.err

        #for replication slave
        #log-slave-updates 
        #sync_binlog = 1

        #for innodb options 
        innodb_data_home_dir = /usr/local/mysql/data/
        innodb_data_file_path = ibdata1:500M:autoextend
        innodb_log_group_home_dir = /usr/local/mysql/arch
        innodb_log_files_in_group = 2
        innodb_log_file_size = 200M

        ****innodb_buffer_pool_size = 2048M ****
        innodb_additional_mem_pool_size = 50M
        innodb_log_buffer_size = 16M

        innodb_lock_wait_timeout = 100
        #innodb_thread_concurrency = 0
        innodb_flush_log_at_trx_commit = 1
        innodb_locks_unsafe_for_binlog=1

        #innodb io features: add for mysql5.5.8
        performance_schema
        innodb_read_io_threads=4
        innodb-write-io-threads=4
        innodb-io-capacity=200
        #purge threads change default(0) to 1 for purge
        innodb_purge_threads=1
        innodb_use_native_aio=on

        #case-sensitive file names and separate tablespace
        innodb_file_per_table = 1
        lower_case_table_names=1

        [mysqldump]
        quick
        max_allowed_packet = 16M

        [mysql]
        no-auto-rehash

        [mysqlhotcopy]
        interactive-timeout

        [myisamchk]
        key_buffer_size = 256M
        sort_buffer_size = 256M
        read_buffer = 2M
        write_buffer = 2M
    修改innodb_buffer_pool_size = 2048M其为innodb_buffer_pool_size = 1024M

yum –y install gcc-g77

12.赋予权限
赋予my.cnf权限:
    # chown mysqladmin:dba /etc/my.cnf
    # chmod 640 /etc/my.cnf
赋予mysql权限:
    # chown -R mysqladmin:dba /usr/local/mysql
    # chmod -R 755 /usr/local/mysql

yum –y install autoconf

13.创建文件夹,归档文件
mkdir arch

yum –y install automake

14.第一次安装
scripts/mysql_install_db  --user=mysqladmin --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 

yum –y install zlib*

15.如果安装的时候发现缺少libaio版本,那么久进行以下操作
查看一下版本:
    cat /proc/version
rpm -qa | grep gcc
yum -y install libaio

yum –y install fiex*

16.切换到mysql根目录
cd /usr/local/mysql

yum –y install libxml*

17.将服务文件拷贝到init.id下,并重命名为mysql
cp support-files/mysql.server /etc/rc.d/init.d/mysql 

yum –y install libmcrypt*

18.赋予可执行权限
chmod +x /etc/rc.d/init.d/mysql

yum –y install libtool-ltdl-devel*

19.删除服务
chkconfig --del mysql

yum -y install make

20.添加服务
chkconfig --add mysql

yum –y install bison

21.设置开机自启动:
chkconfig --level 345 mysql on

yum -y install ncurses-devel

22.删除mysql中的my.cnf
rm -rf my.cnf
bin/mysqld_safe &
如果不可以,先卸载依赖包,再修改权限
    rpm --nodeps -e mysql-libs-5.1.71-1.el6.x86_64
    chmod -R 775 /var/log 

 

23.启动mysql
netstat -tulnp | grep mysql

二. 编译安装 cmake

24.登录MySQL
# mysql
    > show databases;
    > use mysql;
    > update user set password=password('123456') where user='root';
    > select host,user,password from user;
    > delete from user where user='';
    > select host,user,password from user;
    >flush privileges;

重新安装

rm -rf data
rm -rf arch/*
scripts/mysql_install_db  --user=mysqladmin --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 

如果没有报错强行退出会报

swap的错误
改正:
    rm -f .my.cnf.swaf
之后重新编译

【来自@若泽大数据】

cd /usr/local/src

tar zxvf cmake-2.8.7.tar.gz

cd cmake-2.8.7

./bootstrap

gmake

gmake install

cd ../

三. 编译安装 MySQL 5.6.11

创建mysql用户及mysql组

#/usr/sbin/groupadd mysql

#/usr/sbin/useradd –r -g mysql mysql

#cd /install

#tar xvf mysql-5.6.11.tar.gz

#cd mysql-5.6.11/

 

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql

-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock

-DDEFAULT_CHARSET=utf8

-DDEFAULT_COLLATION=utf8_general_ci

-DWITH_EXTRA_CHARSETS=utf8,gbk

-DWITH_PERFSCHEMA_STORAGE_ENGINE=1

-DWITH_FEDERATED_STORAGE_ENGINE=1

-DWITH_PARTITION_STORAGE_ENGINE=1

-DWITH_ARCHIVE_STORAGE_ENGINE=1

-DMYSQL_DATADIR=/usr/local/mysql/data

-DSYSCONFDIR=/usr/local/mysql

-DMYSQL_TCP_PORT=3306


cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock
-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS=utf8,gbk -DWITH_PERFSCHEMA_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1
-DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/usr/local/mysql
-DMYSQL_TCP_PORT=3306


make

make install

 

ln -s /usr/local/mysql/lib/libmysqlclient.so.18
/usr/lib/libmysqlclient.so.18(暂不执行)

[[email protected]
mysql-5.6.10]# mkdir -p /usr/local/mysql/data

[[email protected]
mysql-5.6.10]# chown -R mysql:mysql /usr/local/mysql/data

[[email protected]
mysql-5.6.10]# mkdir -p  /var/mysql/log/

[[email protected]
mysql-5.6.10]# chown -R mysql:mysql /var/mysql/log/         

 

chmod +w /usr/local/mysql

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

 

[[email protected]
mysql-5.6.10]#

[[email protected]
data]# chown –R mysql:mysql
/usr/local/mysql/data/mysql-bin.index(暂不执行)

#cd /usr/loca/mysql/support-files/

#cp my-default.cnf /etc/my.cnf

#cp mysql.server /etc/init.d/mysqld

 

四. 配置启动MySQL 5.6.10

  1. 若有需要请先修改 mysql 的配置文件的参数 my.cnf

vi /etc/my.cnf    

[mysqld] 下添加

basedir = /usr/local/mysql   

datadir = /usr/local/mysql/data

socket = /usr/local/mysql/data/mysql.sock

pid-file = /usr/local/mysql/data/mysqld.pid

interactive_timeout=28800000

wait_timeout=28800000

lower_case_table_names=1

 

2.my.cnf mysql 初始化安装

/usr/local/mysql/scripts/mysql_install_db –defaults-file=/etc/my.cnf
–basedir=/usr/local/mysql –datadir=/usr/local/mysql/data –user=mysql

 

  1. 将 mysql 加入开机启动

chmod +x /etc/init.d/mysqld

vi /etc/init.d/mysqld (编辑此文件,查找并修改以下变量内容:)

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

 

添加mysqld服务

#chkconfig –add mysqld

#chkconfig –level 2345 mysqld on

 

  1. 启动 mysql服务

service mysqld start

 


启动 mysql 服务的时候报如下错误:

Fatal error: Can’t open and lock privilege tables: Table ‘mysql.host’
doesn’t exist

解决方法:

mysql_install_db –user=mysql  重新初始化数据库即可


 

  1. 设置root帐号密码

[[email protected]
~]# /usr/local/mysql/bin/mysqladmin -uroot password root**

[[email protected]
~]# /usr/local/mysql/bin/mysql -uroot -p

Enter password:

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

Your MySQL connection id is 2

Server version: 5.6.11 Source distribution

Copyright (c) 2000, 2013, 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.

64位MySQL 5.6.11 CMake安装部署
一、下载所需软件 linux用 wget 下载需要的软件,保存到目录 /usr/local/src
下 wget ftp://mirror.switch.ch/mirror/m…

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图