微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Linux系统下mariadb数据库的基本操作

修改数据库密码
[root@svr ~]#MysqLadmin –uroot -p(旧密码) password ‘新密码
设置字体格式utf8
[root@svr ~]#vim /etc/my.cnf
character_set_server=utf8
进入数据库
MysqL –uroot –ppwd@123(中间不能有空格 如果有空格,会认为空格后面是一个数据库的)

Linux系统下mariadb数据库的基本操作

数据库语句以分号;结尾 或者\g
查看数据库表 show databases;

Linux系统下mariadb数据库的基本操作

Linux系统下mariadb数据库的基本操作

使用数据库:use 数据库名;
查看数据库表:show tables;

创建数据库 create database ntdad1903;数据库名不能为纯数字(有些版本不能以数字开头),不能是关键字

Linux系统下mariadb数据库的基本操作

删除数据库 drop database 库名;
创建数据库
create table 表名(列名 类型(长度),列名 类型(长度),…….);

Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


describe base; 查看数据库描述

表中插入数据:
Insert into 表名 values (‘值1’,‘值2’……);(value 值与表字段对应)

Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作

删除某一条数据:

Linux系统下mariadb数据库的基本操作


表格复制 利用已有的表格复制一份新的表格

Linux系统下mariadb数据库的基本操作


参照原有表格结构 创建新的表格

Linux系统下mariadb数据库的基本操作


更改表格结构:
alter table 表名 modify 列名 字符类型(长度); 重新定义字符长度
alter table 表名 modify 列名 字符类型(长度) frist; 定义列的位置 放在第一位
alter table 表名 modify 列名 字符类型(长度) after 列名;定义列的位置 放在某一列的后面
alter table 表名 change 旧列名 新列名

Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


一次插入多条数据

Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Select 选择 选取 查询 从数据表中提取出需要的内容
1、 选择表格中的所有记录
Select from 表名
2、 选取表格中符合条件的部分记录
Select
from 表名 where 列名=’列名’;
3、 选取表格中所有记录的部分属性
Select 列名 from 表名 ;
Where 语句的作用 确定操作的是那些记录
主要影响 update select delete 三种操作

Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


整理查询结果
聚集函数 针对频繁使用的功能/方法 预先编写好的代码

Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


Linux系统下mariadb数据库的基本操作


备份数据库(导出):MysqLdump -u用户名 –p密码 数据库名 >备份文件名.sql

Linux系统下mariadb数据库的基本操作


数据库恢复(导入):MysqL 备份文件名.sql < 数据库

Linux系统下mariadb数据库的基本操作

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐