CentOS7安装MySQL5.6.27数据库

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: #####################CentOS7安装MySQL数据库############################ 查看linux系统信息: CentOS-7-x86_64-DVD-1503-01.iso MySQL-client-5.6.27-1.el6.x86_64.rpm  MySQL-devel-5.6.27-1.el6.x86_64.rpm  My

#####################CentOS7安装MySQL数据库############################

查看linux系统信息:

CentOS-7-x86_64-DVD-1503-01.iso

MySQL-client-5.6.27-1.el6.x86_64.rpm 
MySQL-devel-5.6.27-1.el6.x86_64.rpm 
MySQL-server-5.6.27-1.el6.x86_64.rpm

[root@localhost etc]# cat /etc/issue
\S
Kernel \r on an \m
[root@localhost etc]# uname -a
Linux localhost.localdomain 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost etc]# cat /proc/version 
Linux version 3.10.0-229.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) ) #1 SMP Fri Mar 6 11:36:42 UTC 2015

1:检查是否安装MySQL:

方法1:

[root@localhost ~]# yum list installed mysql*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: mirrors.btte.net
 * updates: mirrors.opencas.cn
Error: No matching Packages to list
方法2:
[root@localhost ~]# rpm -qa | grep -i mysql
[root@localhost ~]# 
2:查看yum服务器可下载mysql的版本信息:
[root@localhost ~]# yum list | grep mysql
3:看着yum服务器有没有合适的安装包:
[root@localhost ~]# yum list mysql*
 
安装前:注:之前安装过MySQL或者有残留,请查看: CentOS下MySQL的彻底卸载
               注:遇到问题请查看: CentOS7安装MySQL冲突和问题解决小结
 
4:yum安装MySQL:
 #安装MySQL客户端
 [root@localhost ~]# yum install mysql
 #安装MySQL服务端
 [root@localhost ~]# yum install mysql-server
 #安装MySQL的库和头文件
 [root@localhost ~]# yum install mysql-devel
5:rpm安装MySQL:
1:下载mysql安装包(全):
    http://mysql.mirrors.pair.com/Downloads/
    http://ftp.kaist.ac.kr/mysql/Downloads/   (推荐)
2:已准备安装rpm文件:
[root@localhost install-files]# pwd
/home/install-files
[root@localhost install-files]# ll
总用量 241452
-rw-r--r--. 1 root root   9106353 10月  8 23:15 apache-tomcat-8.0.24.tar.gz
-rw-r--r--. 1 root root 160084320 10月  8 23:17 jdk-8u60-linux-x64.rpm
-rw-r--r--. 1 root root  18596528 10月 11 13:24 MySQL-client-5.6.27-1.el6.x86_64.rpm
-rw-r--r--. 1 root root   3392620 10月 11 13:24 MySQL-devel-5.6.27-1.el6.x86_64.rpm
-rw-r--r--. 1 root root  55950588 10月 11 13:25 MySQL-server-5.6.27-1.el6.x86_64.rpm
-rw-r--r--. 1 root root     98362 10月  8 23:45 sshpass-1.05.tar.gz3
3:安装MySQL服务端:
[root@localhost install-files]# rpm -ivh MySQL-server-5.6.27-1.el6.x86_64.rpm --nosignature
Preparing...                          ################################# [100%]
Updating / installing...
   1:MySQL-server-5.6.27-1.el6        ################################# [100%]
……………………
省略log,文章后备注附件。
检查:
[root@localhost bin]# mysql --version
mysql  Ver 14.14 Distrib 5.6.27, for Linux (x86_64) using  EditLine wrapper
安装服务器遇到错误和警告: CentOS7安装MySQL冲突和问题解决小结
问题1:file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64………
问题2:warning: MySQL-server-5.5.46-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
问题3:mysqld: unrecognized service
问题4:FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db:  Data::Dumper
问题5: Starting MySQL... ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).
4:安装MySQL的库和头文件:
[root@localhost install-files]# rpm -ivh MySQL-devel-5.6.27-1.el6.x86_64.rpm --nosignature
Preparing...                          ################################# [100%]
Updating / installing...
   1:MySQL-devel-5.6.27-1.el6         ################################# [100%]

5:安装MySQL客户端:
[root@localhost install-files]# rpm -ivh MySQL-client-5.6.27-1.el6.x86_64.rpm --nosignature
Preparing...                          ################################# [100%]
Updating / installing...
   1:MySQL-client-5.6.27-1.el6        ################################# [100%]
检验:
[root@localhost bin]# find /usr/bin -name mysqladmin
/usr/bin/mysqladmin
[root@localhost bin]# find /usr/bin -name mysqldump
/usr/bin/mysqldump

注:以下操作rpm和yum安装完成之后操作为一致。
以上安装为默认路径安装,如果要设置路径rpm参数(--relocate,--badreloc):
mysql安装目录:
 1.数据库目录
 /var/lib/mysql/
 2.配置文件
 /usr/share/mysql(mysql.server命令及配置文件)
 3.启动脚本
 /etc/rc.d/init.d/(启动脚本文件mysql的目录) 
 4.相关命令
 /usr/bin(mysqladmin mysqldump等命令)


 注:1~3安装server安装后存在,4mysqladmin mysqldump在client安装后存在
6:启动和关闭mysql:
[root@localhost init.d]# pwd
/etc/rc.d/init.d
[root@localhost init.d]# ls
functions  jexec  mysql  netconsole  network  README
[root@localhost install-files]# service mysql start
Starting MySQL.. SUCCESS! 
[root@localhost install-files]# service mysql stop
Shutting down MySQL.. SUCCESS! 
这个版本安装的mysql的启动脚本为mysql而非mysqld。
问题:
问题3:mysqld: unrecognized service
问题5: Starting MySQL... ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).
查看MySQL日志: cat /var/log/messages | grep mysqld
查看路径,检查文件是否缺少:/var/lib/mysql/
[root@localhost mysql]# ll
total 110620
-rw-rw----. 1 mysql mysql       56 Oct 11 23:20 auto.cnf
-rw-rw----. 1 mysql mysql 12582912 Oct 11 23:20 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Oct 11 23:20 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Oct 11 23:19 ib_logfile1
-rw-r-----. 1 mysql root      5847 Oct 11 23:20 localhost.localdomain.err
drwx--x--x. 2 mysql mysql     4096 Oct 11 23:19 mysql
drwx------. 2 mysql mysql     4096 Oct 11 23:19 performance_schema
-rw-r--r--. 1 root  root       111 Oct 11 23:19 RPM_UPGRADE_HISTORY
-rw-r--r--. 1 mysql mysql      111 Oct 11 23:19 RPM_UPGRADE_MARKER-LAST
drwxr-xr-x. 2 mysql mysql        6 Oct 11 23:19 test
 备注附件:
[root@localhost install-files]# tar -xvf MySQL-5.6.22-1.linux_glibc2.5.x86_64.rpm-bundle.tar
 MySQL-shared-compat-5.6.22-1.linux_glibc2.5.x86_64.rpm     #RHEL兼容包 
 MySQL-client-5.6.22-1.linux_glibc2.5.x86_64.rpm       #MySQL客户端程序
 MySQL-shared-5.6.22-1.linux_glibc2.5.x86_64.rpm    #MySQL的共享库
 MySQL-server-5.6.22-1.linux_glibc2.5.x86_64.rpm        #MySQL服务端程序
 MySQL-test-5.6.22-1.linux_glibc2.5.x86_64.rpm        #MySQL的测试组件
 MySQL-devel-5.6.22-1.linux_glibc2.5.x86_64.rpm        #MySQL的库和头文件
 MySQL-embedded-5.6.22-1.linux_glibc2.5.x86_64.rpm       #MySQL的嵌入式程序

备注安装成功日志:
2015-10-11 23:19:40 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-10-11 23:19:40 0 [Note] /usr/sbin/mysqld (mysqld 5.6.27) starting as process 3168 ...
2015-10-11 23:19:40 3168 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-10-11 23:19:40 3168 [Note] InnoDB: The InnoDB memory heap is disabled
2015-10-11 23:19:40 3168 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-10-11 23:19:40 3168 [Note] InnoDB: Memory barrier is not used
2015-10-11 23:19:40 3168 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-10-11 23:19:40 3168 [Note] InnoDB: Using Linux native AIO
2015-10-11 23:19:40 3168 [Note] InnoDB: Using CPU crc32 instructions
2015-10-11 23:19:40 3168 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-10-11 23:19:40 3168 [Note] InnoDB: Completed initialization of buffer pool
2015-10-11 23:19:40 3168 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-10-11 23:19:40 3168 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-10-11 23:19:40 3168 [Note] InnoDB: Database physically writes the file full: wait...
2015-10-11 23:19:40 3168 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-10-11 23:19:41 3168 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-10-11 23:19:43 3168 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-10-11 23:19:43 3168 [Warning] InnoDB: New log files created, LSN=45781
2015-10-11 23:19:43 3168 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-10-11 23:19:43 3168 [Note] InnoDB: Doublewrite buffer created
2015-10-11 23:19:43 3168 [Note] InnoDB: 128 rollback segment(s) are active.
2015-10-11 23:19:43 3168 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-10-11 23:19:43 3168 [Note] InnoDB: Foreign key constraint system tables created
2015-10-11 23:19:43 3168 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-10-11 23:19:43 3168 [Note] InnoDB: Tablespace and datafile system tables created.
2015-10-11 23:19:43 3168 [Note] InnoDB: Waiting for purge to start
2015-10-11 23:19:43 3168 [Note] InnoDB: 5.6.27 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2015-10-11 23:19:44 3168 [Note] Binlog end
2015-10-11 23:19:44 3168 [Note] InnoDB: FTS optimize thread exiting.
2015-10-11 23:19:44 3168 [Note] InnoDB: Starting shutdown...
2015-10-11 23:19:46 3168 [Note] InnoDB: Shutdown completed; log sequence number 1625977

2015-10-11 23:19:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-10-11 23:19:46 0 [Note] /usr/sbin/mysqld (mysqld 5.6.27) starting as process 3190 ...
2015-10-11 23:19:46 3190 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-10-11 23:19:46 3190 [Note] InnoDB: The InnoDB memory heap is disabled
2015-10-11 23:19:46 3190 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-10-11 23:19:46 3190 [Note] InnoDB: Memory barrier is not used
2015-10-11 23:19:46 3190 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-10-11 23:19:46 3190 [Note] InnoDB: Using Linux native AIO
2015-10-11 23:19:46 3190 [Note] InnoDB: Using CPU crc32 instructions
2015-10-11 23:19:46 3190 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-10-11 23:19:46 3190 [Note] InnoDB: Completed initialization of buffer pool
2015-10-11 23:19:46 3190 [Note] InnoDB: Highest supported file format is Barracuda.
2015-10-11 23:19:46 3190 [Note] InnoDB: 128 rollback segment(s) are active.
2015-10-11 23:19:46 3190 [Note] InnoDB: Waiting for purge to start
2015-10-11 23:19:46 3190 [Note] InnoDB: 5.6.27 started; log sequence number 1625977
2015-10-11 23:19:46 3190 [Note] Binlog end
2015-10-11 23:19:46 3190 [Note] InnoDB: FTS optimize thread exiting.
2015-10-11 23:19:46 3190 [Note] InnoDB: Starting shutdown...
2015-10-11 23:19:49 3190 [Note] InnoDB: Shutdown completed; log sequence number 1625987

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

  /usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.

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 /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
大概安装步骤:
[root@localhost install-files]# rpm -ivh MySQL-client-5.6.27-1.el6.x86_64.rpm --nosignature
……
[root@localhost install-files]# rpm -ivh MySQL-devel-5.6.27-1.el6.x86_64.rpm --nosignature
……
[root@localhost install-files]# yum remove mysql-libs
……
[root@localhost lib]# rm -rf /var/lib/mysql
……
[root@localhost install-files]# yum install -y perl-Module-Install.noarch
……
[root@localhost install-files]# rpm -ivh MySQL-server-5.6.27-1.el6.x86_64.rpm --nosignature
……
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
7天前
|
关系型数据库 MySQL 分布式数据库
《MySQL 简易速速上手小册》第6章:MySQL 复制和分布式数据库(2024 最新版)
《MySQL 简易速速上手小册》第6章:MySQL 复制和分布式数据库(2024 最新版)
37 2
|
4天前
|
SQL 存储 关系型数据库
数据库开发之mysql前言以及详细解析
数据库开发之mysql前言以及详细解析
14 0
|
1天前
|
缓存 NoSQL 关系型数据库
在Python Web开发过程中:数据库与缓存,MySQL和NoSQL数据库的主要差异是什么?
MySQL与NoSQL的主要区别在于数据结构、查询语言和可扩展性。MySQL是关系型数据库,依赖预定义的数据表结构,使用SQL进行复杂查询,适合垂直扩展。而NoSQL提供灵活的存储方式(如JSON、哈希表),无统一查询语言,支持横向扩展,适用于处理大规模、非结构化数据和高并发场景。选择哪种取决于应用需求、数据模型及扩展策略。
10 0
|
3天前
|
Linux
centos 6.5安装yum
centos 6.5安装yum
22 0
|
3天前
|
运维 网络协议 Linux
【运维系列】Centos7安装并配置PXE服务
PXE是Intel开发的预启动执行环境,允许工作站通过网络从远程服务器启动操作系统。它依赖DHCP分配IP,DNS服务分配主机名,TFTP提供引导程序,HTTP/FTP/NFS提供安装源。要部署PXE服务器,需关闭selinux和防火墙,安装dhcpd、httpd、tftp、xinetd及相关服务,配置引导文件和Centos7安装源。最后,通过syslinux安装引导文件,并创建pxelinux.cfg/default配置文件来定义启动参数。
15 0
|
3天前
|
运维 网络协议 Linux
【运维系列】Centos7安装并配置postfix服务
安装CentOS7的Postfix和Dovecot,配置Postfix的`main.cf`文件,包括修改完全域名、允许所有IP、启用邮箱等。然后,配置Dovecot的多个配置文件以启用auth服务和调整相关设置。重启Postfix和Dovecot,设置开机自启,并关闭防火墙进行测试。最后,创建邮箱账户并在Windows邮箱客户端中添加账户设置。
10 0
|
3天前
|
Linux 网络安全
Centos6.5安装并配置NFS服务
该内容描述了在Linux系统中设置NFS服务的步骤。首先挂载yum源,然后安装NFS服务,并编辑配置文件。接着,重启rpcbind和NFS服务,可能需要重复此过程以解决初始可能出现的问题。此外,关闭防火墙策略,并再次重启服务。最终,根目录被共享,特定IP网段被允许访问。
10 0
|
4天前
|
存储 Linux 网络安全
centos7使用yum网络安装
这些是使用Yum进行网络安装的基本步骤。根据你的需求,你可以重复步骤3和4来安装其他软件包。请注意,执行Yum操作需要root或具有sudo权限的用户。
16 1
|
3天前
|
SQL 存储 关系型数据库
MySQL Cluster集群安装及使用
MySQL Cluster集群安装及使用
|
7天前
|
关系型数据库 MySQL 数据库
《MySQL 简易速速上手小册》第1章:MySQL 基础和安装(2024 最新版)
《MySQL 简易速速上手小册》第1章:MySQL 基础和安装(2024 最新版)
29 4