CentOS 7.4 如何安装 MariaDB 10.3.9 Stable 数据库
CentOS 7.4 如何安装 MariaDB 10.3.9 Stable 数据库
一、CentOS 7.4上卸载 Mariadb 数据库
1.查询所安装的MariaDB组件
[libin@VM_0_9_centos ~]$ sudo rpm -qa | grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
mariadb-server-5.5.60-1.el7_5.x86_64
mariadb-5.5.60-1.el7_5.x86_64
2.卸载数据库
[libin@VM_0_9_centos ~]$ sudo rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
[libin@VM_0_9_centos ~]$ sudo rpm -aq|grep mariadb
mariadb-server-5.5.60-1.el7_5.x86_64
mariadb-5.5.60-1.el7_5.x86_64
3.删除数据库文件
# 删除数据库的其它配置文件
[root@VM_0_9_centos ~]# sudo rm -rf /var/lib/mysql/*
[libin@VM_0_9_centos ~]$ sudo yum -y remove mariadb*
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.60-1.el7_5 will be erased
---> Package mariadb-server.x86_64 1:5.5.60-1.el7_5 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================
Package Arch Version Repository Size
===========================================================================================================
Removing:
mariadb x86_64 1:5.5.60-1.el7_5 @updates 49 M
mariadb-server x86_64 1:5.5.60-1.el7_5 @updates 58 M
Transaction Summary
===========================================================================================================
Remove 2 Packages
Installed size: 107 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 4 pre-existing rpmdb problem(s), 'yum check' output follows:
perl-DBD-MySQL-4.023-6.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)
perl-DBD-MySQL-4.023-6.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)
Erasing : 1:mariadb-server-5.5.60-1.el7_5.x86_64 1/2
warning: /var/log/mariadb/mariadb.log saved as /var/log/mariadb/mariadb.log.rpmsave
Erasing : 1:mariadb-5.5.60-1.el7_5.x86_64 2/2
Verifying : 1:mariadb-server-5.5.60-1.el7_5.x86_64 1/2
Verifying : 1:mariadb-5.5.60-1.el7_5.x86_64 2/2
Removed:
mariadb.x86_64 1:5.5.60-1.el7_5 mariadb-server.x86_64 1:5.5.60-1.el7_5
Complete!
[libin@VM_0_9_centos ~]$
二、CentOS 7.4上安装 MariaDB 10.3.9 Stable 数据库
1.添加MariaDB的yum源
1.1、创建MariaDB.repo
在/etc/yum.repos.d/MariaDB.repo文件里创建即可。
[libin@VM_0_9_centos ~]$ sudo vim /etc/yum.repos.d/Mariadb.repo
1.2、将以下文件中的字段添加到MariaDB.repo文件中
1.2.1、使用官网的源
# MariaDB 10.3 CentOS repository list - created 2018-08-31 07:59 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
注意:上面这个是官网上的源,可惜我大中华...,必须使用代理,否则慢的一匹,用下面这个清华的源是很快的。
1.2.2、使用清华的源
# MariaDB 10.3 CentOS repository list - created 2018-08-31 07:59 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos7-amd64/
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
2.yum安装MariaDB
[libin@VM_0_9_centos ~]$ sudo yum -y install MariaDB-server MariaDB-client
3.启动MariaDB服务
启动MariaDB服务
[libin@VM_0_9_centos ~]$ sudo systemctl start mysql.service
设置开机启动
[libin@VM_0_9_centos ~]$ sudo systemctl enable mysql.service
禁止开机重启
[libin@VM_0_9_centos ~]$ sudo systemctl disable mysql.service
或者
systemctl start mariadb.service #启动MariaDB
systemctl stop mariadb.service #停止MariaDB
systemctl restart mariadb.service #重启MariaDB
systemctl enable mariadb.service #设置开机启动
4.配置MariaDB服务
[libin@VM_0_9_centos ~]$ sudo mysql_secure_installation
[libin@VM_0_9_centos root]$ sudo mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
#由于一开始安装MariaDB数据库后, root用户默认密码为空, 所以只需要按Enter键
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
#是否设置root用户的新密码
Set root password? [Y/n] y
#录入新密码
New password:
#确认新密码
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
#是否删除匿名用户,生产环境建议删除
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
#是否禁止root远程登录,根据自己的需求选择
Disallow root login remotely? [Y/n] n
... skipping.
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
#是否删除test数据库
Remove test database and access to it? [Y/n] n
... skipping.
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
#是否重新加载权限表
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
具体设置:
#由于一开始安装MariaDB数据库后, root用户默认密码为空, 所以只需要按Enter键
Enter current password for root (enter for none):
#是否设置root用户的新密码
Set root password? [Y/n] y
#录入新密码
New password:
#确认新密码
Re-enter new password:
#是否删除匿名用户,生产环境建议删除
Remove anonymous users? [Y/n] y
#是否禁止root远程登录,根据自己的需求选择
Disallow root login remotely? [Y/n] n
#是否删除test数据库
Remove test database and access to it? [Y/n] y
#是否重新加载权限表
Reload privilege tables now? [Y/n] y
5.开启远程访问
5.1、防火墙添加3306端口
- 查看firewall状态
[libin@VM_0_9_centos ~]$ sudo firewall-cmd --state
状态是not running,启动firewall,systemctl start firewalld。
状态是running,说明firewalld已经开启。
- 开放3306端口
[libin@VM_0_9_centos ~]$ sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
- 重新载入
[libin@VM_0_9_centos ~]$ sudo firewall-cmd --reload
- 查看所有打开的端口
[libin@VM_0_9_centos ~]$ sudo firewall-cmd --zone=public --list-ports
5.2、开启root开启远程访问,去MariaDB赋权限
- 进入Mariadb
[libin@VM_0_9_centos ~]$ sudo mysql -uroot -p
- 选择数据库
MariaDB [test]> use mysql;
- 添加权限
MariaDB [mysql]> Grant all on *.* to 'root'@'%' identified by 'root' with grant option;
Query OK, 0 rows affected (0.000 sec)
- 重新载入
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.000 sec)
三、MariaDB数据库的使用
- 查看MariaDB的版本
MariaDB [mysql]> select version();
+----------------+
| version() |
+----------------+
| 10.3.9-MariaDB |
+----------------+
1 row in set (0.000 sec)
参考资料:
- https://www.cnblogs.com/zenghua/p/7149646.html
- Downloads MariaDB最新版
- http://www.cnblogs.com/river2005/p/6813618.html
- https://blog.csdn.net/junehappylove/article/details/78690743
- https://blog.csdn.net/sunny05296/article/details/56015884/
CentOS 7.4 如何安装 MariaDB 10.3.9 Stable 数据库的更多相关文章
- CentOS使用rpm离线安装mariadb
本文不再更新,可能存在内容过时的情况,实时更新请移步原文地址:CentOS使用rpm离线安装mariadb: 环境: CentOS Linux release 7.6.1810 (Core) mari ...
- CentOS 7.x编译安装Nginx1.10.3+MySQL5.7.16+PHP5.2 5.3 5.4 5.5 5.6 7.0 7.1多版本全能环境
准备篇 一.防火墙配置 CentOS 7.x默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.se ...
- 在 CentOS 7.2 上安装 ODOO 10 (2018-10-09 持续更新)
在 CentOS 7.2 上安装 ODOO 10 更新系统 yum update 安装 EPEL 源 1 yum install -y epel-release 安装依赖组件 yum install ...
- CentOS 7.4 下面安装 jdk 10 的一点总结
CentOS 7.4 下面安装 jdk 10 的一点总结 一.前期工作 1.检验系统原版本 [root@zck ~]# java -version java version "1.7.0_& ...
- linux下编译安装MariaDB 10.4.7,解决错误:cannot access ‘/auth_pam_tool_dir’: No such file or directory
编译安装MariaDB 10.4.7,前面的步骤我就不复述了,一切正常没什么问题. 当执行到:scripts/mysql_install_db --basedir=/usr/local/mysql - ...
- CentOS 7安装MariaDB 10详解以及相关配置
第一步:添加 MariaDB yum 仓库 首先在CentOS操作系统中/etc/yum.repos.d/目录下添加 MariaDB 的YUM配置文件MariaDB.repo文件. vi /etc/y ...
- CentOS7下安装Mariadb 10.3.17
1. install lsb packagesudo yum install -y redhat-lsb 2.install net-tools packagesudo yum install -y ...
- centos6.5环境使用RPM包离线安装MariaDB 10.0.20
1. 进入MariaDB官网下载MariaDB需要的RPM包 2. 使用下载软件下载所需要的RPM包, 总共4个, 并上传到CentOS主机指定目录. MariaDB-10.0.20-centos6- ...
- CentOS 7.4编译安装Nginx1.10.3+MySQL5.7.16
准备篇 一.防火墙配置 CentOS 7.x默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.se ...
随机推荐
- Rsync+inotify自动同步数据
一.简介 随着应用系统规模的不断扩大,对数据的安全性和可靠性也提出的更好的要求,rsync在高端业务系统中也逐渐暴露出了很多不足. 首先,rsync在同步数据时,需要扫描所有文件后进行比对,进行差量传 ...
- margin和padding
一.margin基础语法与结构 1.margin语法 Margin:10px Margin的值是数字+html单位,同时也可以为auto(自动.自适应) 2.应用结构 Div{margin:10px} ...
- jedis在线文档网址
jedis在线文档网址:http://tool.oschina.net/apidocs/apidoc?api=jedis-2.1.0
- python socket和简单tcp通信实现
python 服务端和客户端的简单交互 TCP服务端: 1 创建套接字,绑定套接字到本地IP与端口 s = socket.socket(socket.AF_INET,socket.SOCK_STREA ...
- 图论&数学:矩阵树定理
运用矩阵树定理进行生成树计数 给定一个n个点m条边的无向图,问生成树有多少种可能 直接套用矩阵树定理计算即可 矩阵树定理的描述如下: 首先读入无向图的邻接矩阵,u-v G[u][v]++ G[v][u ...
- 冒泡排序Bubble sort
原理是临近的数字两两进行比较,按照从小到大或者从大到小的顺序进行交换, 这样一趟过去后,最大或最小的数字被交换到了最后一位, 然后再从头开始进行两两比较交换,直到倒数第二位时结束,其余类似看例子 例子 ...
- ? 初识Webx 2
初识Webx 1: http://www.cnblogs.com/lddbupt/p/5547189.html Webx Framework负责完成一系列基础性的任务. 比如系统初始化和响应请求. 系 ...
- 【NOIP】2013 花匠
[算法]贪心 [题解] DP可以f[i][0],f[i][1]表示选了i分别满足条件AB的答案,其优化也是利用了下面的性质,不多赘述. 想象数列的波动,最大值一定是取每个波峰和每个波谷,那么只要O(n ...
- 集合类HashMap,HashTable,ConcurrentHashMap区别?
1.HashMap 简单来说,HashMap由数组+链表组成的,数组是HashMap的主体,链表则是主要为了解决哈希冲突而存在的,如果定位到的数组位置不含链表(当前entry的next指向null), ...
- 【洛谷 P4051】 [JSOI2007]字符加密(后缀数组)
题目链接 两眼题.. 第一眼裸SA 第二眼要复制一倍再跑SA. 一遍过.. #include <cstdio> #include <cstring> #include < ...