MySQL5.7.2二进制安装

由于MySQL5.7.2还没有正式发布,需要到http://labs.mysql.com/ 下载MySQL Multi-source Replication版本。

文件名为:mysql-5.7.2-labs-multi-src-rep-linux-glibc2.5-x86_64.tar.gz

完整链接:http://downloads.mysql.com/snapshots/pb/mysql-multi-src-repl/mysql-5.7.2-labs-multi-src-rep-linux-glibc2.5-x86_64.tar.gz

实验环境

操作系统:

[root@localhost etc]# lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:
graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 6.4 (Santiago)
Release:        6.4
Codename:       Santiago
[root@localhost etc]# 

一般安装步骤:

  • 添加mysql用户组,并创建mysql用户到mysql用户组
  • 解压mysql-VERSION-OS.tar.gz文件到/usr/local文件夹,并建立链接到/usr/local/mysql文件夹
  • 对mysql文件夹进行权限以及用户组设置
  • 运行安装脚本,完成mysql安装
  • 运行mysql
  • 将mysql自动启动脚本加入到启动项中
  • 配置mysql环境变量
  • 测试启动与关闭mysql服务
  • 测试数据库

1、创建mysql用户组,并将mysql用户添加到mysql用户组

[root@localhost soft]# groupadd mysql
[root@localhost soft]# useradd -r -g mysql mysql

2、解压mysql-VERSION-OS.tar.gz文件到/usr/local文件夹,并建立链接到/usr/local/mysql文件夹

[root@localhost soft]# cd /usr/local
[root@localhost local]# tar zxvf /soft/mysql-5.7.2-labs-multi-src-rep-linux-glibc2.5-x86_64.tar.gz 
[root@localhost local]# ln -s mysql-5.7.2-labs-multi-src-rep-linux-glibc2.5-x86_64/ mysql
[root@localhost local]# cd mysql

3、对mysql文件夹进行权限以及用户组设置

[root@localhost local]# cd mysql
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .

4、运行安装脚本,完成mysql安装

[root@localhost mysql]# scripts/mysql_install_db --user=mysql 
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql data

5、运行mysql

[root@localhost mysql]# bin/mysqld_safe –user=mysql &

6、将mysql自动启动脚本加入到启动项中

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql

[root@localhost conf]# chkconfig –add mysql

加入自动启动项

7、配置Mysql系统环境变量,编辑/etc/profile文件

找到export PATH

在前面添加export PATH=$PATH:/usr/local/mysql/bin

[root@localhost ~]# vi /etc/profile

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

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

添加Mysql环境变量之后,使用source /etc/profile命令使环境变量及时生效,命令如下:

[root@localhost ~]# source /etc/profile

8、编辑/etc/my.cnf文件

[root@localhost ~]# vi /etc/my.cnf
#password       = your_password
port            = 3306
socket          = /tmp/mysql.sock
# The MySQL server
[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 2M
max_allowed_packet = 1M
table_open_cache = 2048
sort_buffer_size = 2M
net_buffer_length = 16K
read_buffer_size = 6M
read_rnd_buffer_size = 3M
myisam_sort_buffer_size = 2M

#skip-networking

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin

# binary logging format - mixed recommended
binlog_format=mixed

server-id       = 1
log-bin=mysql-bin
[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 2M
sort_buffer_size = 3M
read_buffer = 6M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

9、使用命令启动和关闭mysql数据库

[root@localhost ~]# service mysql status
MySQL running (5098)                                       [  OK  ]
[root@localhost ~]# service mysql restart
Shutting down MySQL..                                      [  OK  ]
Starting MySQL…                                          [  OK  ]
[root@localhost ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.7.2-labs-multi-src-rep-log MySQL Community Server (GPL)

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.

mysql> show databases;
+——————–+
| Database           |
+——————–+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+——————–+
4 rows in set (0.00 sec)

mysql> \q
Bye
[root@localhost ~]#

附件为:my.cnf配置文件的参考示例

至此,我们完成了MySQL 5.7.2的二进制版本的安装。

『–ENDOF–』

Comments are closed.