Mysql 5.6.18解压包版在Rhel6.7上安装

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介:

Mysql的安装方式有三种:RPM包、二进程包和源码包。


RPM

二进制

源码

优点

安装简单,适合初学者学习使用

安装简单;可以安装到任何路径下,灵活性好;一台服务器可以安装多个MySQL

在实际安装的操作系统进行可根据需要定制编译,最灵活;性能最好;一台服务器可以安装多个MySQL

缺点

需要单独下载客户端和服务器;安装路径不灵活,默认路径不能修改,一台服务器只能安装一个MySQL

已经经过编译,性能不如源码编译得好;不能灵活定制编译参数

安装过程较复杂;编译时间长

文件布局

/usr/bin(客户端程序和脚本)

/usr/sbinmysqld服务器)/var/lib/mysql(日志文件和数据库)/usr/share/doc/packages(文档)

/usr/include/mysql(包含()文件)

/usr/lib/mysql(库文件)/usr/share/mysql(错误消息和字符集文件)/usr/share/sql-bench(基准程序)

bin(客户端程序和mysqld服务器)

data(日志文件和数据库)docs(文档和ChangeLoginclude(包含()文件)lib(库文件)

scripts mysql_install_db脚本,用来安装系统数据库)

share/mysql(错误消息文件)

sql-bench(基准程序)

bin(客户端程序和脚本)include/mysql(包含()文件)

infoInfo格式的文档)lib/mysql(库文件)

libexecmysqld服务器)、share/mysql(错误消息文件)

sql-bench(基准程序和crash-me测试)

var(数据库和日志文件)

摘自深入浅出MySQL

1、配置环境和创建用户

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@rhel6 ~] # mkdir /opt/mysql
[root@rhel6 ~] # mkdir /mysqldata
[root@rhel6 ~] # groupadd mysql
[root@rhel6 ~] # useradd -r -g mysql -s /bin/flase mysql
[root@rhel6 ~] # chown mysql:mysql /opt/mysql
[root@rhel6 ~] # chown mysql:mysql /mysqldata
--关闭selinux
[root@rhel6 ~] # vi /etc/selinux/config 
SELINUX=disabled
--配置环境变量
[root@rhel6 scripts] # vi ~/.bash_profile 
--添加下面两条
export  MYSQL_PATH= /opt/mysql/mysql5 .6.18
export  PATH=$PATH:$MYSQL_PATH /bin
[root@rhel6 scripts] # source ~/.bash_profile

2、上传并解压安装包

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@rhel6 ~] # cd /opt/mysql/
[root@rhel6 mysql] # ls
mysql-advanced-5.6.18-linux-glibc2.5-x86_64. tar .gz
[root@rhel6 mysql] # tar -zxvf mysql-advanced-5.6.18-linux-glibc2.5-x86_64.tar.gz 
mysql-advanced-5.6.18-linux-glibc2.5-x86_64 /bin/mysql_convert_table_format
mysql-advanced-5.6.18-linux-glibc2.5-x86_64 /bin/mysql_client_test
mysql-advanced-5.6.18-linux-glibc2.5-x86_64 /bin/mysqlhotcopy
mysql-advanced-5.6.18-linux-glibc2.5-x86_64 /bin/mysqladmin
mysql-advanced-5.6.18-linux-glibc2.5-x86_64 /bin/msql2mysql
......
 
[root@rhel6 mysql] # mv mysql-advanced-5.6.18-linux-glibc2.5-x86_64 mysql5.6.18
[root@rhel6 mysql] # ll
total 306412
drwxr-xr-x 13 root root      4096 Nov 13 20:38 mysql5.6.18
-rw-r--r--  1 root root 313754429 Nov 13 20:37 mysql-advanced-5.6.18-linux-glibc2.5-x86_64. tar .gz
[root@rhel6 mysql] # chown -R mysql:mysql mysql5.6.18/
[root@rhel6 mysql] # ll
total 306412
drwxr-xr-x 13 mysql mysql      4096 Nov 13 20:38 mysql5.6.18
-rw-r--r--  1 root  root  313754429 Nov 13 20:37 mysql-advanced-5.6.18-linux-glibc2.5-x86_64. tar .gz

3、安装mysql

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
64
65
[root@rhel6 mysql] # cd /opt/mysql/mysql5.6.18/support-files/
[root@rhel6 support-files] # ls
binary-configure  magic  my-default.cnf  mysqld_multi.server  mysql-log-rotate  mysql.server  solaris
[root@rhel6 support-files] # cd /opt/mysql/mysql5.6.18/scripts/
[root@rhel6 scripts] # ls
mysql_install_db
[root@rhel6 scripts] # ./mysql_install_db --user=mysql --basedir=/opt/mysql/mysql5.6.18 --datadir=/mysqldata
WARNING: The host  'rhel6'  could not be looked up with  /opt/mysql/mysql5 .6.18 /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...2016-11-13 20:42:18 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation  for  more  details).2016-11-13 20:42:18 1421 [Note] InnoDB: Using atomics to ref count buffer pool pages
......
OK
 
Filling help tables...2016-11-13 20:42:21 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation  for  more  details).
......
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:
 
   /opt/mysql/mysql5 .6.18 /bin/mysqladmin  -u root password  'new-password'
   /opt/mysql/mysql5 .6.18 /bin/mysqladmin  -u root -h rhel6 password  'new-password'
 
Alternatively you can run:
 
   /opt/mysql/mysql5 .6.18 /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  . ;  /opt/mysql/mysql5 .6.18 /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  /opt/mysql/mysql5 .6.18 /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

可以看到安装完成后mysql会给出一些提示、建议。

4、复制相关文件

1
2
3
[root@rhel6 scripts] # cp /opt/mysql/mysql5.6.18/support-files/mysql.server /etc/init.d/mysqld
[root@rhel6 scripts] # cp /opt/mysql/mysql5.6.18/support-files/my-default.cnf /etc/my.cnf 
cp : overwrite ` /etc/my .cnf'?  yes

注意不要使用系统自带的/etc/my.cnf文件,否则启动mysql服务时会报错。

Starting MySql.. ERROR! The server quit without updating PID file(/var/mysql/data/rhel6.pid).

5、修改参数

1
2
3
4
[root@rhel6 scripts] # vi /etc/init.d/mysqld
##修改下面两个参数如下
basedir= /opt/mysql/mysql5 .6.18
datadir= /mysqldata

6、加入开机启动

1
2
3
[root@rhel6 scripts] # chkconfig --levels 235 mysqld on
[root@rhel6 scripts] # chkconfig --list mysqld
mysqld             0:off   1:off   2:on    3:on    4:on    5:on    6:off

7、启动mysql服务

1
2
[root@rhel6 scripts] # service mysqld start
Starting MySQL. SUCCESS!

8、连接mysql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@rhel6 scripts] # mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection  id  is 1
Server version: 5.6.18-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)
 
Copyright (c) 2000, 2014, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
test                |
+--------------------+
4 rows  in  set  (0.00 sec)

9、mysql的帮助

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
64
65
66
67
68
69
70
71
72
73
1.用“?contents”命令来显示所有可供查询的的分类
mysql> ? contents
You asked  for  help about help category:  "Contents"
For  more  information,  type  'help <item>' , where <item> is one of the following
categories:
    Account Management
    Administration
    Compound Statements
    Data Definition
    Data Manipulation
    Data Types
    Functions
    Functions and Modifiers  for  Use with GROUP BY
    Geographic Features
    Help Metadata
    Language Structure
    Plugins
    Procedures
    Storage Engines
    Table Maintenance
    Transactions
    User-Defined Functions
    Utility
 
mysql> help data types
You asked  for  help about help category:  "Data Types"
For  more  information,  type  'help <item>' , where <item> is one of the following
topics:
    AUTO_INCREMENT
    BIGINT
    BINARY
    BIT
    BLOB
    BLOB DATA TYPE
    BOOLEAN
    CHAR
    CHAR BYTE
    DATE
    DATETIME
    DEC
    DECIMAL
    DOUBLE
    DOUBLE PRECISION
    ENUM
    FLOAT
    INT
    INTEGER
    LONGBLOB
    LONGTEXT
    MEDIUMBLOB
    MEDIUMINT
    MEDIUMTEXT
    SET DATA TYPE
    SMALLINT
    TEXT
    TIME
    TIMESTAMP
    TINYBLOB
    TINYINT
    TINYTEXT
    VARBINARY
    VARCHAR
    YEAR DATA TYPE
 
mysql> help int
Name:  'INT'
Description:
INT[(M)] [UNSIGNED] [ZEROFILL]
 
A normal-size integer. The signed range is -2147483648 to 2147483647.
The unsigned range is 0 to 4294967295.
 
URL: http: //dev .mysql.com /doc/refman/5 .6 /en/numeric-type-overview .html


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





相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
19小时前
|
关系型数据库 MySQL Linux
Linux下安装MySQL
Linux下安装MySQL
4 0
|
2天前
|
关系型数据库 MySQL 数据库
mysqlTools 一分钟部署安装本mysql多个版本,解锁繁琐部署过程
mysqlTools 一分钟部署安装本mysql多个版本,解锁繁琐部署过程
62 2
|
4天前
|
关系型数据库 MySQL Linux
本地虚拟机centos7通过docker安装主从mysql5.7.21
本地虚拟机centos7通过docker安装主从mysql5.7.21
11 0
|
5天前
|
关系型数据库 MySQL 数据库
龙蜥操作系统上安装MySQL:步骤详解与常见问题解决
龙蜥操作系统上安装MySQL:步骤详解与常见问题解决
|
5天前
|
关系型数据库 MySQL Linux
在Centos7中:通过Docker安装MySQL5.7(保姆级)
在Centos7中:通过Docker安装MySQL5.7(保姆级)
|
5天前
|
编解码 安全 关系型数据库
祝福CSDN的小伙伴2024年快乐!Windows7安装MySQL
祝福CSDN的小伙伴2024年快乐!Windows7安装MySQL
|
7天前
|
关系型数据库 MySQL Linux
Linux CentOs7 安装Mysql(5.7和8.0版本)密码修改 超详细教程
Linux CentOs7 安装Mysql(5.7和8.0版本)密码修改 超详细教程
|
8天前
|
安全 关系型数据库 MySQL
MySQL安装教程
MySQL安装教程
29 0
|
8天前
|
SQL 关系型数据库 MySQL
【简单无脑】自动化脚本一键安装虚拟机下的MySQL服务
该文章提供了在虚拟机上安装MySQL服务的简化方法,特别是针对新手。作者提供了一个自动化脚本`install_mysql.sh`,使得安装过程更简单。用户需要下载`install.rpm`资源,将其放在指定目录下,然后创建并编辑脚本文件,将提供的代码粘贴进去,通过`chmod u+x`授权,最后运行脚本`./install_mysql.sh [rpm文件路径]`来安装MySQL。文章还附有相关图片说明。
21 1
【简单无脑】自动化脚本一键安装虚拟机下的MySQL服务
|
8天前
|
SQL 缓存 关系型数据库
MySQL常见问题解决和自动化安装脚本
这篇内容包含了两个主要部分:解决MySQL登录问题和处理GPG密钥问题。当MySQL密码正确但无法登录时,可以通过执行SQL命令`ALTER USER`和`flush privileges`来修改和重置密码。对于MySQL安装时的GPG密钥错误,首先需要强制删除旧的MySQL仓库包,导入新的GPG公钥,然后安装MySQL服务器。如果遇到GPG检查错误,可以使用`--nogpgcheck`参数忽略检查来安装。最后,提供了一个自动化安装MySQL的脚本,用于检查旧版本、卸载残留、安装MySQL8并启动服务。
22 1
MySQL常见问题解决和自动化安装脚本