MySQL5.6--------基于CentOS6二进制包安装

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:

1. 背景

   * MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品。MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件。

   * MySQL是一种关系数据库管理系统,关系数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。

   * MySQL所使用的 SQL 语言是用于访问数据库的最常用标准化语言。MySQL 软件采用了双授权政策,分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,一般中小型网站的开发都选择 MySQL 作为网站数据库。


2. 选择的理由

   * 支持多种平台[AIX、FreeBSD、HP-UX、Linux、Mac OS、OpenBSD、Solaris、Windows......]

   * 支持并提供多语言API

   * 开源,采用了 GPL协议,可以修改源码来开发自己的 MySQL 系统

   * 支持标准SQL语句

   * 支持多种存储引擎

   * 使用广泛 [ 全球top20网站除微软的Live和Bing之外全部应用MySQL ]

wKioL1lOX5jQoVFpAAFaXeTnnpM723.jpg


3. MySQL安装方式

   * 二制包安装

   * 源码编译安装

   * 平台安装包,如rpm包[centos,redhat]或deb[debian,ubuntu]包


4. 环境 [关闭selinux]

1
2
3
4
5
6
7
8
[root@MySQL ~] # cat /etc/redhat-release 
CentOS release 6.9 (Final)
 
[root@MySQL ~] # uname -r
2.6.32-642.3.1.el6.x86_64
 
[root@MySQL ~] # getenforce 
Disabled


5. 安装

   * 下载MySQL5.6二进制包 [ 推荐从MySQL官方下载 ]

1
[root@MySQL ~] # wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz


   * 解压MySQL二进制包

1
[root@MySQL ~] # tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz

 

   * 移动MySQL二进制包

1
[root@MySQL ~] # mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/


   * 创建软链接

1
[root@MySQL ~] # ln -s /usr/local/mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql


   * 创建 mysql 用户

1
[root@MySQL ~] # useradd -r -s /sbin/nologin mysql


   * 创建mysql数据库文件存放目录

1
[root@MySQL ~] # mkdir -p /data/mysql_data


   * 修改二进制包目录与数据目录所属用户与所属用户组

1
[root@MySQL ~] # chown mysql.mysql -R /usr/local/mysql-5.6.36-linux-glibc2.5-x86_64 /data/mysql_data


   * 复制默认配置文件至/etc/my.cnf

1
[root@MySQL ~] # cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf


   * MySQL初始化 [ 创建数据库相关文件 ] 看到两个OK并没有ERROR错误信息表明初始化成功

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
[root@MySQL ~] # /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data 
WARNING: The host  'MySQL'  could not be looked up with  /usr/local/mysql/bin/resolveip .
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
 
Installing MySQL system tables...2017-06-24 03:57:47 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation  for  more  details).
2017-06-24 03:57:47 0 [Note] Ignoring --secure- file -priv value as server is running with --bootstrap.
2017-06-24 03:57:47 0 [Note]  /usr/local/mysql/bin/mysqld  (mysqld 5.6.36) starting as process 20685 ...
2017-06-24 03:57:47 20685 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-06-24 03:57:47 20685 [Note] InnoDB: The InnoDB memory heap is disabled
2017-06-24 03:57:47 20685 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-06-24 03:57:47 20685 [Note] InnoDB: Memory barrier is not used
2017-06-24 03:57:47 20685 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-06-24 03:57:47 20685 [Note] InnoDB: Using Linux native AIO
2017-06-24 03:57:47 20685 [Note] InnoDB: Using CPU crc32 instructions
2017-06-24 03:57:47 20685 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-06-24 03:57:47 20685 [Note] InnoDB: Completed initialization of buffer pool
2017-06-24 03:57:47 20685 [Note] InnoDB: The first specified data  file  . /ibdata1  did not exist: a new database to be created!
2017-06-24 03:57:47 20685 [Note] InnoDB: Setting  file  . /ibdata1  size to 12 MB
2017-06-24 03:57:47 20685 [Note] InnoDB: Database physically writes the  file  full: wait...
2017-06-24 03:57:47 20685 [Note] InnoDB: Setting log  file  . /ib_logfile101  size to 48 MB
2017-06-24 03:57:49 20685 [Note] InnoDB: Setting log  file  . /ib_logfile1  size to 48 MB
2017-06-24 03:57:51 20685 [Note] InnoDB: Renaming log  file  . /ib_logfile101  to . /ib_logfile0
2017-06-24 03:57:51 20685 [Warning] InnoDB: New log files created, LSN=45781
2017-06-24 03:57:51 20685 [Note] InnoDB: Doublewrite buffer not found: creating new
2017-06-24 03:57:51 20685 [Note] InnoDB: Doublewrite buffer created
2017-06-24 03:57:51 20685 [Note] InnoDB: 128 rollback segment(s) are active.
2017-06-24 03:57:51 20685 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-06-24 03:57:51 20685 [Note] InnoDB: Foreign key constraint system tables created
2017-06-24 03:57:51 20685 [Note] InnoDB: Creating tablespace and datafile system tables.
2017-06-24 03:57:51 20685 [Note] InnoDB: Tablespace and datafile system tables created.
2017-06-24 03:57:51 20685 [Note] InnoDB: Waiting  for  purge to start
2017-06-24 03:57:52 20685 [Note] InnoDB: 5.6.36 started; log sequence number 0
2017-06-24 03:57:58 20685 [Note] Binlog end
2017-06-24 03:57:58 20685 [Note] InnoDB: FTS optimize thread exiting.
2017-06-24 03:57:58 20685 [Note] InnoDB: Starting  shutdown ...
2017-06-24 03:58:00 20685 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
 
Filling help tables...2017-06-24 03:58:00 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation  for  more  details).
2017-06-24 03:58:00 0 [Note] Ignoring --secure- file -priv value as server is running with --bootstrap.
2017-06-24 03:58:00 0 [Note]  /usr/local/mysql/bin/mysqld  (mysqld 5.6.36) starting as process 20731 ...
2017-06-24 03:58:00 20731 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-06-24 03:58:00 20731 [Note] InnoDB: The InnoDB memory heap is disabled
2017-06-24 03:58:00 20731 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-06-24 03:58:00 20731 [Note] InnoDB: Memory barrier is not used
2017-06-24 03:58:00 20731 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-06-24 03:58:00 20731 [Note] InnoDB: Using Linux native AIO
2017-06-24 03:58:00 20731 [Note] InnoDB: Using CPU crc32 instructions
2017-06-24 03:58:00 20731 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-06-24 03:58:00 20731 [Note] InnoDB: Completed initialization of buffer pool
2017-06-24 03:58:00 20731 [Note] InnoDB: Highest supported  file  format  is Barracuda.
2017-06-24 03:58:00 20731 [Note] InnoDB: 128 rollback segment(s) are active.
2017-06-24 03:58:00 20731 [Note] InnoDB: Waiting  for  purge to start
2017-06-24 03:58:00 20731 [Note] InnoDB: 5.6.36 started; log sequence number 1625977
2017-06-24 03:58:00 20731 [Note] Binlog end
2017-06-24 03:58:00 20731 [Note] InnoDB: FTS optimize thread exiting.
2017-06-24 03:58:00 20731 [Note] InnoDB: Starting  shutdown ...
2017-06-24 03:58:02 20731 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK


6. 创建启动脚本

   * 复制启动脚本到service 服务管理目录下[ /etc/init.d ]

1
[root@MySQL ~] # cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld


   * 修改mysql启动脚本 [ /et/init.d/mysqld ]

1
2
basedir= /usr/local/mysql
datadir= /data/mysql_data


   * 添加脚本执行权限

1
[root@MySQL ~] # chmod +x /etc/init.d/mysqld


   * 添加进service服务管理

1
[root@MySQL ~] # chkconfig --add mysqld


7. 服务启动测试

   * 启动 MySQL 服务

1
2
3
[root@MySQL ~] # /etc/init.d/mysqld start
Starting MySQL.Logging to  '/data/mysql_data/MySQL.err' .
  SUCCESS!


   * 查看服务是否启动并监听端口 [默认3306]

1
2
[root@MySQL ~] # netstat -lntp | grep 3306
tcp        0      0 :::3306           :::*             LISTEN        21366 /mysqld


8. 连接测试并修改密码

   * 通过自带mysql客户端连接

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@MySQL ~] # /usr/local/mysql/bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection  id  is 1
Server version: 5.6.36 MySQL Community Server (GPL)
 
Copyright (c) 2000, 2017, 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.
 
Type  'help;'  or  '\h'  for  help. Type  '\c'  to  clear  the current input statement.
 
mysql>


   * 修改密码

1
2
mysql>  set  password = password( '123456' );
Query OK, 0 rows affected (0.00 sec)


   * 重新使用密码连接

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
mysql> quit
Bye
[root@MySQL ~] # /usr/local/mysql/bin/mysql
ERROR 1045 (28000): Access denied  for  user  'root' @ 'localhost'  (using password: NO)
 
[root@MySQL ~] # /usr /local/mysql/bin/mysql -p123456
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 3
Server version: 5.6.36 MySQL Community Server (GPL)
 
Copyright (c) 2000, 2017, 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.
 
Type  'help;'  or  '\h'  for  help. Type  '\c'  to  clear  the current input statement.
 
mysql>



9. 总结


以需求驱动技术,技术本身没有优略之分,只有业务之分。




      本文转自asd1123509133 51CTO博客,原文链接:http://blog.51cto.com/lisea/1941595,如需转载请自行联系原作者




相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
4月前
|
关系型数据库 MySQL Linux
Centos下脚本安装MySQL(tar.gz)
Centos下脚本安装MySQL(tar.gz)
88 2
|
8月前
|
关系型数据库 MySQL Linux
centos7上mysql的二进制安装
centos7上mysql的二进制安装
|
关系型数据库 MySQL Linux
Linux安装二进制Mysql
Linux安装二进制Mysql
95 0
Linux安装二进制Mysql
|
存储 Ubuntu 关系型数据库
Mysql 源码安装与二进制安装
mysql的安装与初始化
1110 0
Mysql 源码安装与二进制安装
|
安全 关系型数据库 MySQL
mysql 5.7.14二进制包安装
操作系统版本: [root@Darren2 ~]# cat /etc/redhat-release CentOS release 6.5 (Final) 操作系统内核: [root@Darren2 ~]# uname -r 2.
791 0
|
关系型数据库 MySQL 数据安全/隐私保护
|
Ubuntu 关系型数据库 MySQL
|
关系型数据库 MySQL