CentOS 6.5上安装MariaDB

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介: 版权声明:本文为博主chszs的原创文章,未经博主允许不得转载。 https://blog.csdn.net/chszs/article/details/20483431 CentOS 6.5上安装MariaDB作者:chszs,转载需注明。
版权声明:本文为博主chszs的原创文章,未经博主允许不得转载。 https://blog.csdn.net/chszs/article/details/20483431

CentOS 6.5上安装MariaDB

作者:chszs,转载需注明。博客主页: http://blog.csdn.net/chszs

1、软件环境:

CentOS 6.5 x64
MariaDB 5.5.36

2、安装过程

1)在/etc/yum.repos.d/目录创建MariaDB.repo文件,内容如下:
# MariaDB 5.5 CentOS repository list - created 2014-03-04 11:20 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

2)在Shell环境下执行命令
# yum install MariaDB-server MariaDB-client
Loaded plugins: fastestmirror, security
base                                                                                       | 3.7 kB     00:00     
base/primary_db                                                                            | 4.4 MB     01:11     
extras                                                                                     | 3.4 kB     00:00     
extras/primary_db                                                                          |  19 kB     00:00     
mariadb                                                                                    | 1.9 kB     00:00     
mariadb/primary_db                                                                         |  15 kB     00:00     
updates                                                                                    | 3.4 kB     00:00     
updates/primary_db                                                                         | 2.1 MB     00:22     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-client.x86_64 0:5.5.36-1.el6 will be obsoleting
--> Processing Dependency: MariaDB-common for package: MariaDB-client-5.5.36-1.el6.x86_64
---> Package MariaDB-server.x86_64 0:5.5.36-1.el6 will be obsoleting
---> Package mysql.x86_64 0:5.1.71-1.el6 will be obsoleted
---> Package mysql-server.x86_64 0:5.1.71-1.el6 will be obsoleted
--> Running transaction check
---> Package MariaDB-common.x86_64 0:5.5.36-1.el6 will be installed
--> Processing Dependency: MariaDB-compat for package: MariaDB-common-5.5.36-1.el6.x86_64
--> Running transaction check
---> Package MariaDB-compat.x86_64 0:5.5.36-1.el6 will be obsoleting
---> Package mysql-libs.x86_64 0:5.1.71-1.el6 will be obsoleted
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================
 Package                        Arch                   Version                      Repository               Size
==================================================================================================================
Installing:
 MariaDB-client                 x86_64                 5.5.36-1.el6                 mariadb                  10 M
     replacing  mysql.x86_64 5.1.71-1.el6
 MariaDB-compat                 x86_64                 5.5.36-1.el6                 mariadb                 2.7 M
     replacing  mysql-libs.x86_64 5.1.71-1.el6
 MariaDB-server                 x86_64                 5.5.36-1.el6                 mariadb                  42 M
     replacing  mysql-server.x86_64 5.1.71-1.el6
Installing for dependencies:
 MariaDB-common                 x86_64                 5.5.36-1.el6                 mariadb                  23 k

Transaction Summary
==================================================================================================================
Install       4 Package(s)

Total download size: 55 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): MariaDB-5.5.36-centos6-x86_64-client.rpm                                            |  10 MB     04:45     
(2/4): MariaDB-5.5.36-centos6-x86_64-common.rpm                                            |  23 kB     00:00     
(3/4): MariaDB-5.5.36-centos6-x86_64-compat.rpm                                            | 2.7 MB     01:02     
(4/4): MariaDB-5.5.36-centos6-x86_64-server.rpm                                            |  42 MB     17:44     
------------------------------------------------------------------------------------------------------------------
Total                                                                              40 kB/s |  55 MB     23:34     
warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY
Retrieving key from https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Importing GPG key 0x1BB943DB:
 Userid: "Daniel Bartholomew (Monty Program signing key) <dbart@askmonty.org>"
 From  : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : MariaDB-compat-5.5.36-1.el6.x86_64                                                             1/7 
  Installing : MariaDB-common-5.5.36-1.el6.x86_64                                                             2/7 
Error in PREIN scriptlet in rpm package MariaDB-server-5.5.36-1.el6.x86_64

******************************************************************
A MySQL or MariaDB server package (mysql-server-5.1.71-1.el6.x86_64) is installed.

The current MariaDB server package is provided by a different
vendor (CentOS) than Monty Program AB.  Some files may be installed
to different locations, including log files and the service
startup script in /etc/init.d/.

Upgrading directly from MySQL 5.1 to MariaDB 5.5 may not
be safe in all cases.  A manual dump and restore using mysqldump is
recommended.  It is important to review the MariaDB manual's Upgrading
section for version-specific incompatibilities.

A manual upgrade is required.

- Ensure that you have a complete, working backup of your data and my.cnf
  files
- Shut down the MySQL server cleanly
- Remove the existing MySQL packages.  Usually this command will
  list the packages you should remove:
  rpm -qa | grep -i '^mysql-'

  You may choose to use 'rpm --nodeps -ev <package-name>' to remove
  the package which contains the mysqlclient shared library.  The
  library will be reinstalled by the MariaDB-shared package.
- Install the new MariaDB packages supplied by Monty Program AB
- Ensure that the MariaDB server is started
- Run the 'mysql_upgrade' program

This is a brief description of the upgrade process.  Important details
can be found in the MariaDB manual, in the Upgrading section.
******************************************************************
error: %pre(MariaDB-server-5.5.36-1.el6.x86_64) scriptlet failed, exit status 1
error:   install: %pre scriptlet failed (2), skipping MariaDB-server-5.5.36-1.el6
  Installing : MariaDB-client-5.5.36-1.el6.x86_64                                                             4/7 
  Erasing    : mysql-5.1.71-1.el6.x86_64                                                                      5/7 
  Erasing    : mysql-libs-5.1.71-1.el6.x86_64                                                                 6/7 
  Verifying  : MariaDB-common-5.5.36-1.el6.x86_64                                                             1/7 
  Verifying  : MariaDB-compat-5.5.36-1.el6.x86_64                                                             2/7 
  Verifying  : MariaDB-client-5.5.36-1.el6.x86_64                                                             3/7 
  Verifying  : mysql-libs-5.1.71-1.el6.x86_64                                                                 4/7 
  Verifying  : MariaDB-server-5.5.36-1.el6.x86_64                                                             5/7 
mysql-server-5.1.71-1.el6.x86_64 was supposed to be removed but is not!
  Verifying  : mysql-server-5.1.71-1.el6.x86_64                                                               6/7 
  Verifying  : mysql-5.1.71-1.el6.x86_64                                                                      7/7 

Installed:
  MariaDB-client.x86_64 0:5.5.36-1.el6                    MariaDB-compat.x86_64 0:5.5.36-1.el6                   

Dependency Installed:
  MariaDB-common.x86_64 0:5.5.36-1.el6                                                                            

Replaced:
  mysql.x86_64 0:5.1.71-1.el6                           mysql-libs.x86_64 0:5.1.71-1.el6                          

Failed:
  MariaDB-server.x86_64 0:5.5.36-1.el6                     mysql-server.x86_64 0:5.1.71-1.el6                    

Complete!

3、启动MariaDB

# /etc/init.d/mysqld start
Initializing MySQL database:  WARNING: The host 'Cloud-Q2' could not be looked up with 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...
OK
Filling help tables...
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:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h Cloud-Q2 password 'new-password'

Alternatively you can run:
/usr/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 /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

4、为MariaDB设置密码

# /usr/bin/mysqladmin -u root password 'adminadmin'

登陆MariaDB
MySQL [(none)]> use mysql;
MySQL [mysql]> update user set host='%' where user='root' and host='127.0.0.1';
MySQL [mysql]> grant all privileges on *.* to 'root'@'%' identified by 'adminadmin' with grant option;
MySQL [mysql]> flush privileges;

5、让防火墙通过3306端口
# vi /etc/sysconfig/iptables

添加如下内容:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

保存并退出编辑
重启防火墙服务
# service iptables restart

远程连接检查,一切OK!







相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
23天前
|
消息中间件 Linux API
centos7 安装rabbitmq自定义版本及配置
centos7 安装rabbitmq自定义版本及配置
|
30天前
|
安全 关系型数据库 MySQL
Linux(CentOS6)安装MySQL5.6
Linux(CentOS 6)系统上安装MySQL 5.6版本的详细步骤,包括准备数据存放目录、创建用户、下载安装包、初始化数据库、配置服务脚本、设置环境变量等操作。
99 1
|
1月前
|
关系型数据库 MySQL Java
centos7安装mysql教程及Navicat平替软件
【8月更文挑战第17天】本教程详述CentOS 7上安装MySQL的过程。首先确保移除任何预装的MySQL组件,然后通过wget获取并安装MySQL的YUM源。可以选择安装特定版本如5.7或8.0。安装MySQL服务器后,启动服务并查找初始密码。登录MySQL后应立即更改密码,并可根据需要设置远程访问权限。此外,还推荐使用免费开源的DBeaver作为数据库管理工具,提供了安装步骤以方便管理和操作MySQL数据库。
|
22天前
|
弹性计算 关系型数据库 MySQL
centos7 mysql安装及配置
本文详细介绍了在阿里云服务器ECS上通过yum源安装MySQL 8.0.12的过程,包括更新yum源、下载并安装MySQL源、解决安装过程中可能遇到的问题等步骤。此外,还介绍了如何启动MySQL服务、设置开机自启、配置登录密码、添加远程登录用户以及处理远程连接异常等问题。适合初学者参考,帮助快速搭建MySQL环境。
110 8
centos7 mysql安装及配置
|
19天前
|
存储 Linux Docker
CentOS 7.6安装Docker实战案例及存储引擎和服务进程简介
关于如何在CentOS 7.6上安装Docker、介绍Docker存储引擎以及服务进程关系的实战案例。
64 3
CentOS 7.6安装Docker实战案例及存储引擎和服务进程简介
|
30天前
|
Linux 开发工具 数据安全/隐私保护
CentOS7安装流程步骤详细教程
【8月更文挑战第22天】
215 2
CentOS7安装流程步骤详细教程
|
1月前
|
应用服务中间件 Linux 网络安全
2022年超详细在CentOS 7上安装Nginx方法(源码安装)
这篇文章提供了在CentOS 7系统上通过源码安装Nginx的详细步骤,包括从官网下载Nginx源码包、上传至虚拟机、解压、删除压缩包、编译安装前的配置、安装PCRE库(因为Nginx使用PCRE库解析正则表达式)、安装zlib和OpenSSL库(用于支持HTTPS协议)、重新编译Nginx、安装后启动Nginx服务、关闭服务、修改默认端口、以及重启服务测试等步骤。文章还提供了相关命令和操作截图,帮助用户更好地理解和执行安装过程。
2022年超详细在CentOS 7上安装Nginx方法(源码安装)
|
23天前
|
分布式计算 资源调度 Hadoop
centos7二进制安装Hadoop3
centos7二进制安装Hadoop3
|
28天前
|
Linux 开发工具 git
CentOS安装git客户端
【8月更文挑战第22天】在 CentOS 上安装 Git 可通过两种方式:一是利用 yum 包管理器,只需在终端依次执行 `sudo yum update` 和 `sudo yum install git` 命令,安装时按提示输入 y 即可;二是从源码安装,适用于有特殊需求的场景。首先安装必要的依赖库,然后下载并解压 Git 的源码包,最后通过一系列 make 命令完成配置与编译安装。无论哪种方式,安装完毕后均可通过 `git --version` 验证安装情况。
|
26天前
|
缓存 运维 Linux
深入解析:一步步掌握 CentOS 7 安装全流程及运维实战技巧
深入解析:一步步掌握 CentOS 7 安装全流程及运维实战技巧