阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

MySQL5.6.18解压包版在RHEL6.7上安装

387次阅读
没有评论

共计 7015 个字符,预计需要花费 18 分钟才能阅读完成。

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

摘自 深入浅出 MySQL  PDF 下载见 http://www.linuxidc.com/Linux/2016-05/130922.htm

1、配置环境和创建用户

[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、上传并解压安装包

[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

[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、复制相关文件

[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、修改参数

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

6、加入开机启动

[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 服务

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

8、连接 mysql

[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. 用“?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

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-02/140523.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计7015字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中

星哥玩云

星哥玩云
星哥玩云
分享互联网知识
用户数
4
文章数
19352
评论数
4
阅读量
8052719
文章搜索
热门文章
星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛 NAS-6:抖音视频同步工具,视频下载自动下载保存 前言 各位玩 NAS 的朋友好,我是星哥!...
星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛 NAS-3:安装飞牛 NAS 后的很有必要的操作 前言 如果你已经有了飞牛 NAS 系统,之前...
再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见 zabbix!轻量级自建服务器监控神器在 Linux 的完整部署指南 在日常运维中,服务器监控是绕不开的...
飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛 NAS 中安装 Navidrome 音乐文件中文标签乱码问题解决、安装 FntermX 终端 问题背景 ...
免费领取huggingface的2核16G云服务器,超简单教程

免费领取huggingface的2核16G云服务器,超简单教程

免费领取 huggingface 的 2 核 16G 云服务器,超简单教程 前言 HuggingFace.co...
阿里云CDN
阿里云CDN-提高用户访问的响应速度和成功率
随机文章
150元打造低成本NAS小钢炮,捡一块3865U工控板

150元打造低成本NAS小钢炮,捡一块3865U工控板

150 元打造低成本 NAS 小钢炮,捡一块 3865U 工控板 一块二手的熊猫 B3 工控板 3865U,搭...
CSDN,你是老太太喝粥——无齿下流!

CSDN,你是老太太喝粥——无齿下流!

CSDN,你是老太太喝粥——无齿下流! 大家好,我是星哥,今天才思枯竭,不写技术文章了!来吐槽一下 CSDN。...
一句话生成拓扑图!AI+Draw.io 封神开源组合,工具让你的效率爆炸

一句话生成拓扑图!AI+Draw.io 封神开源组合,工具让你的效率爆炸

一句话生成拓扑图!AI+Draw.io 封神开源组合,工具让你的效率爆炸 前言 作为天天跟架构图、拓扑图死磕的...
4盘位、4K输出、J3455、遥控,NAS硬件入门性价比之王

4盘位、4K输出、J3455、遥控,NAS硬件入门性价比之王

  4 盘位、4K 输出、J3455、遥控,NAS 硬件入门性价比之王 开篇 在 NAS 市场中,威...
还在找免费服务器?无广告免费主机,新手也能轻松上手!

还在找免费服务器?无广告免费主机,新手也能轻松上手!

还在找免费服务器?无广告免费主机,新手也能轻松上手! 前言 对于个人开发者、建站新手或是想搭建测试站点的从业者...

免费图片视频管理工具让灵感库告别混乱

一言一句话
-「
手气不错
星哥带你玩飞牛NAS-14:解锁公网自由!Lucky功能工具安装使用保姆级教程

星哥带你玩飞牛NAS-14:解锁公网自由!Lucky功能工具安装使用保姆级教程

星哥带你玩飞牛 NAS-14:解锁公网自由!Lucky 功能工具安装使用保姆级教程 作为 NAS 玩家,咱们最...
浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍

浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍

浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍 前言 在 AI 自动化快速发展的当下,浏览器早已不再只是...
安装并使用谷歌AI编程工具Antigravity(亲测有效)

安装并使用谷歌AI编程工具Antigravity(亲测有效)

  安装并使用谷歌 AI 编程工具 Antigravity(亲测有效) 引言 Antigravity...
仅2MB大小!开源硬件监控工具:Win11 无缝适配,CPU、GPU、网速全维度掌控

仅2MB大小!开源硬件监控工具:Win11 无缝适配,CPU、GPU、网速全维度掌控

还在忍受动辄数百兆的“全家桶”监控软件?后台偷占资源、界面杂乱冗余,想查个 CPU 温度都要层层点选? 今天给...
还在找免费服务器?无广告免费主机,新手也能轻松上手!

还在找免费服务器?无广告免费主机,新手也能轻松上手!

还在找免费服务器?无广告免费主机,新手也能轻松上手! 前言 对于个人开发者、建站新手或是想搭建测试站点的从业者...