温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2020-07-28 00:27:38 来源:网络 阅读:1041 作者:纵马且长歌 栏目:MySQL数据库

修改数据库密码:
[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数据库的基本操作

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI