CentOS7下使用yum安装MariaDB
从CentOS 7开始,使用 MariaDB 替代默认的 MySQL。MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。
Linux下安装MariaDB官方文档参见:https://mariadb.com/kb/zh-cn/installing-mariadb-with-yum/
全部删除MySQL/MariaDB
MySQL 已经不再包含在 CentOS 7 的源中,而改用了 MariaDB;
1.使用rpm -qa | grep mariadb搜索 MariaDB 现有的包:
如果存在,使用rpm -e --nodeps mariadb-*全部删除:
[root@localhost ~]# rpm -qa | grep mariadb
[root@localhost ~]# rpm -e mysql-*
2.使用rpm -qa | grep mariadb搜索 MariaDB 现有的包:
如果存在,使用yum remove mysql mysql-server mysql-libs compat-mysql51全部删除;
[root@localhost ~]# yum remove mysql mysql-server mysql-libs compat-mysql51
[root@localhost ~]# rpm -qa|grep mariadb
3.开始新的安装, 创建MariaDB.repo文件
vi /etc/yum.repos.d/MariaDB.repo
插入以下内容:
# MariaDB 10.2.4 CentOS repository list - created 2017-05-05 16:13 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
系统及版本选择:https://downloads.mariadb.org/mariadb/repositories/#mirror=tuna
4.运行安装命令安装MariaDB
[root@localhost ~]# yum -y install MariaDB-server MariaDB-client
首先下载安装包,然后进行自动安装,安装成功之后启动MariaDB服务。
systemctl start mariadb #启动服务
systemctl enable mariadb #设置开机启动
systemctl restart mariadb #重新启动
systemctl stop mariadb.service #停止MariaDB
5.登录到数据库
用mysql -uroot命令登录到MariaDB,此时root账户的密码为空。
6.进行MariaDB的相关简单配置,使用mysql_secure_installation命令进行配置。
mysql_secure_installation
首先是设置密码,会提示先输入密码
Enter current password for root (enter for none):<–初次运行直接回车
设置密码
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
其他配置
Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车,
Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
初始化MariaDB完成,接下来测试登录
mysql -uroot -ppassword
完成。
7.配置MariaDB的字符集
查看/etc/my.cnf文件内容,其中包含一句!includedir /etc/my.cnf.d 说明在该配置文件中引入/etc/my.cnf.d 目录下的配置文件。
1)使用vi server.cnf命令编辑server.cnf文件,在[mysqld]标签下添加
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
如果/etc/my.cnf.d 目录下无server.cnf文件,则直接在/etc/my.cnf文件的[mysqld]标签下添加以上内容。
2)文件/etc/my.cnf.d/client.cnf
vi /etc/my.cnf.d/client.cnf
在[client]中添加
default-character-set=utf8
3)文件/etc/my.cnf.d/mysql-clients.cnf
vi /etc/my.cnf.d/mysql-clients.cnf
在[mysql]中添加
default-character-set=utf8
全部配置完成,重启mariadb
systemctl restart mariadb
之后进入MariaDB查看字符集
mysql> show variables like "%character%";show variables like "%collation%";
显示为

+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec) +----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_unicode_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)
字符集配置完成。
8. 添加用户,设置权限
创建用户命令
mysql>create user username@localhost identified by 'password';
直接创建用户并授权的命令
mysql>grant all on *.* to username@localhost indentified by 'password';
授予外网登陆权限
mysql>grant all privileges on *.* to username@'%' identified by 'password';
授予权限并且可以授权
mysql>grant all privileges on *.* to username@'hostname' identified by 'password' with grant option;
查询各Schema和Table占用的空间:
MariaDB [information_schema]> use information_schema;
MariaDB [information_schema]> select table_schema,round(sum(DATA_LENGTH/1024/1024),2) as datasize from tables group by table_schema;
MariaDB [information_schema]> select table_name,concat(round(sum(data_length/1024/1024),2),'MB') as datasize from tables where table_schema='nemo' group by table_name;
简单的用户和权限配置基本就这样了。
其中只授予部分权限把 其中 all privileges或者all改为select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file其中一部分。
Linux系统教程:如何检查MariaDB服务端版本 http://www.linuxidc.com/Linux/2015-08/122382.htm
MariaDB Proxy读写分离的实现 http://www.linuxidc.com/Linux/2014-05/101306.htm
Linux下编译安装配置MariaDB数据库的方法 http://www.linuxidc.com/Linux/2014-11/109049.htm
CentOS系统使用yum安装MariaDB数据库 http://www.linuxidc.com/Linux/2014-11/109048.htm
安装MariaDB与MySQL并存 http://www.linuxidc.com/Linux/2014-11/109047.htm
CentOS7下使用yum安装MariaDB的更多相关文章
- ECS——CentOS7下使用yum安装MariaDB
CentOS 6 或早期的版本中提供的是 MySQL 的服务器/客户端安装包,但 CentOS 7 已使用了 MariaDB 替代了默认的 MySQL.MariaDB数据库管理系统是MySQL的一个分 ...
- centos7下使用yum安装mysql
CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1. 下载mysql的repo源 wget http://repo.mysql.com/m ...
- centos7下使用yum安装pip
centos7下使用yum安装pip 首先安装epel扩展源: yum -y install epel-release 更新完成之后,就可安装pip: yum -y install python-pi ...
- centos7下使用yum安装redis
centos7下使用yum安装Redis 第一步:安装 yum –y install redis 第二步:启动 systemctl start redis.service 第三步:设置开机启动 sys ...
- CentOS7下使用YUM安装mariadb10
1:由于centos7 默认使用yum安装MySQL的话就会安装mariadb,只是安装的版本停留在mariadb5.x,版本比较低.如果我们需要安装mariadb10这里就需要删除mariadb-l ...
- Centos6下使用yum安装MariaDB
1)增加mariaDB的yum源 1 2 3 4 5 6 7 8 9 [root@centos6-test08 ~]# cd /etc/yum.repos.d/ [root@centos6-test0 ...
- 日常工作问题解决:centos7下使用yum安装软件报yum.pid锁定
问题描述: 在centos7下使用yum进行软件安装时报yum.pid已经被锁定,如下所示: [root@centos7-129 ~]# yum -y install dhcp 已加载插件:faste ...
- Linux下使用yum安装MariaDB
版本:centos7 Linux下安装MariaDB官方文档参见:https://mariadb.com/kb/zh-cn/installing-mariadb-with-yum/ 1.创建Maria ...
- CentOS7 下使用YUM安装 MySQL5.7
于2015年10月19日(美国时间),Oracle公司发布了开源数据库MySQL的最新版本5.7.到现在已有将近3年之久,经过这几年的改进,MySQL5.7性能最高可达前一个版本的3倍,现在官网的最新 ...
随机推荐
- unicorn与nginx通讯--[ruby unix socket]
[龍昌博客] http://www.xefan.com/archives/84146.html unicorn是如何与nginx通讯的——介绍ruby中的unix socket Ruby 应用服务典型 ...
- windows的WSl安装mysql数据库以及操作数据库
1.更新 sudo apt-get update sudo apt-get upgrade 2.安装mysql sudo apt-get install mysql-server 3.开启服务 sud ...
- HTML基础之JS中的序列化和反序列化-----字符串的json类型与字典之间的相互转换
前端向后端传递数据的时候不能直接传递对象(如,字典),只能发字符串,Jason就是一种字符串所以前端向后端发送数据的时候,需要将对象转换成字符串 如果前端向后端发送的是json类型,需要通过JSON. ...
- BZOJ 5093[Lydsy1711月赛]图的价值 线性做法
博主曾更过一篇复杂度为$O( k· \log k)$的多项式做法在这里 惊闻本题有$ O(k)$的神仙做法,说起神仙我就想起了于是就去学习了一波 幂与第二类斯特林数 推导看这里 $$ x^k=\sum ...
- zip4j压缩
使用的jar包:zip4j_1.3.2.jar 基本功能: 针对ZIP压缩文件创建.添加.分卷.更新和移除文件 (读写有密码保护的Zip文件) (支持AES 128/256算法加密) (支持标准Zip ...
- pythonのdjango 在控制台用log打印操作日志
在Django项目的settings.py文件中,在最后复制粘贴如下代码: LOGGING = { 'version': 1, 'disable_existing_loggers': False, ' ...
- 3D Slicer中文教程(八)—导出STL文件
一.STL文件简介 STL(立体平版印刷术的缩写)是由3D Systems创建的立体平版印刷CAD软件原生的文件格式STL有“标准三角语言”和“标准镶嵌语言”等几个事后回溯.这种文件格式是由许多其他软 ...
- CodeForces 587 E.Duff as a Queen 线段树动态维护区间线性基
https://codeforces.com/contest/587/problem/E 一个序列, 1区间异或操作 2查询区间子集异或种类数 题解 解题思路大同小异,都是利用异或的性质进行转化,st ...
- C++关于string的一些用法
#include <iostream> #include <algorithm> #include <functional> using namespace std ...
- xPath Helper插件
xPath Helper插件 xPath helper是一款Chrome浏览器的开发者插件,安装了xPath helper后就能轻松获取HTML元素的xPath,程序员就再也不需要通过搜索html源代 ...