mariadb简介

简述

数据库简单来说就是一个存放数据的仓库,通过按照一定的数据结构来组织存储数据,而我们也可以通过数据库提供的多种方法来管理数据库里的数据。
数据库分为关系型数据库和非关系型数据库

关系型数据库

关系型数据库是把所有复杂的数据结构都归结为简单的二元关系,即二维格式表。在关系型数据库中,对数据的操作几乎全部建立在几个关系表上,通过对这些关联表格分类,合并,连接和选取来实现数据的管理。
优点:

  • 易于维护,都是使用表结构,格式一致
  • 使用方便,SQL语言通用,可用于复杂查询

缺点:

  • 读写性能较差,特别是应对海量数据时读写效率较低
  • 结构固定,灵活度低

常见关系型数据库:oracle,db2,sqlserver,mysql,mariadb

非关系型数据库

非关系型数据库并不是彻底否定关系型数据库,而是作为传统关系型数据库的一个补充,在特定场景可以发挥出难以想象的高效。
非关系型数据库严格意义上不是一种数据库,而是一种数据结构化存储方法的集合。
优点:

  • 格式灵活,不拘泥于表,可以是key,value,文档,图片等等
  • nosql可以使用硬盘或任意存储器作为载体,而关系型数据库只能使用硬盘
  • nosql数据库部署简单,多数是开源软件

缺点:

  • 不能使用SQL语言
  • 数据结构复杂,查询较慢

常见的非关系型数据库:mongodb,redis

mariadb安装使用

下载mariadb千万不要用官方的源(亲测,下到明年也下不下来),建议换成中科院的源

[mariadb]
name = MariaDB
baseurl = http://mirrors.ustc.edu.cn/mariadb/yum/10.2/centos7-amd64/
gpgkey=http://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1

安装好后进行设置,包括设置密码,是否禁止匿名用户登录,是否禁止root远程登录,是否重新加载权限表。

[root@101 yum.repos.d]# 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.

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.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n
 ... skipping.

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.

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.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

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提供mysqld服务,但mariadb还需要许多客户端程序来保证数据库工作进行。

tcp6       0      0 :::3306                 :::*                    LISTEN      10229/mysqld
客户端程序
mysql交互式的client工具
mysqldump数据库备份工具,基于mysql协议向mysqld服务发起查询请求,并将查询到的所有数据转换成insert等写操作语句保存在文件中
mysqladmin基于mysql协议管理mysqld
mysqlimport数据导入工具

其中我们最常用的客户端程序就是mysql

mysql -uuser指定登录用户
mysql -ppassword指定登录密码
mysql -hhost远程登录数据库
mysql -Pport指定端口
mysql -e ‘SQL语句’非交互式的使用SQL语句

mariadb数据

数据类型
整数int,bit
精确值decimal
字符串char,varchar
日期时间date,time,datetime
枚举enum
数值类型字节大小signed有符号范围unsigned无符号范围
tinyint1-128~1270~255
smallint2-32768~327670~65535
mediumint3-8388608~83886070~16777215
int/integer4
bigint8
字符串类型字节大小
char0~255占用字符固定
varchar0~255占用字符随具体字符数变化
text0~65535大文本
日期时间类型字节大小示例
date42019-08-28
time319:25:46
datetime82019-08-28 19:25:46
year12019
timestamp4‘2018-01-01 00:00:01’ UTC ~ ‘2019-01-01 00:00:01’ UTC
约束
主键primary key物理存储的顺序
非空not null该字段不能为空
唯一unique该字段不允许重复
默认default不填写时即为默认值
外键foreign key对关系字段进行约束,填写时会在关联的表中查询,如果查到则填写成功,没有查到则填写失败并返回异常

计算机英语

secure安全
installation安装
dump倾倒
import输入
integer整数
enumerate枚举
primary
unique独特
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值