日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql常用命令集合 及附图操作

發布時間:2025/3/19 数据库 15 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql常用命令集合 及附图操作 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

按電腦左下角window圖標 找到添加的mysql(如果要經常使用 右擊打開文件位置 找到該文件 右擊發送到桌面快捷方式 就行)

1.1打開mysql 輸入你安裝時定下的密碼

?

1.2創建用戶

--創建用戶

create user "tqn"@"localhost" ?identified by "1234";

1.3使用此數據庫

--使用數據庫

use mysql --用戶保存在mysql數據庫中

1.4查看表格

--查詢表

show tables;

1.5查詢用戶

--查詢用戶

select user from user;

1.6修改密碼格式的兩種 看你的系統支持哪個

--修改密碼

set password ?for?"tqn"@"localhost" = PASSWORD("12345");

set password ?for?"tqn"@"localhost" = "12345";

1.7mysql 授權語句報錯 原因是show本身就有不需要二次授權

--授權操作(指定用戶可以)

grant insert, show, update on *.*to "tqn"@"localhost";

grant insert, update on *.*to "tqn"@"localhost";

1.8刪除用戶 然后查詢用戶 記得要加分號啊!

--刪除用戶

drop user "tqn"@"localhost";

1.9查看數據庫

--查詢數據庫

show databases;

?

?

2.1創建一個數據庫

-- 創建數據庫
create database xxxx;

-- 刪除數據庫
drop databse xxxx;

2.2查看數據庫

2.3使用自己創建的這個數據庫

--
use mydatabase;

2.4創建student表

-- 創建表(tinyint -128+127)
create table student(
id int unsigned not null primary key auto_increment,
name char(10) not null,
age tinyint unsigned not null );

或者

-- 創建表(tinyint - 128 + 127)(支持中文格式的char字符輸入)
create table student(
?? ?id int unsigned not null primary key auto_increment,
?? ?name char(10) not null,
?? ?age tinyint unsigned not null) charset utf8;

2.5查看表結構

-- 查看表結構
describe student;

2.6修改表 添加生日信息 加在id后面

-- 修改表 添加一個生日 加在id后面
alter table student add birthday date after id;

-- 查看表結構
describe student;

2.7刪除id 查看一下

-- 刪除id
alter table student drop id;

-- 查看表結構
describe student;

2.8再把id加回來 順便加一個電話號碼 默認11個杠 查看一下表信息

-- 再把它加回來
alter table student add id int unsigned not null primary key auto_increment first;

-- 添加電話 默認11個杠
alter table student add id char(11) default "-";

2.9重命名表格

-- 修改表的名字
alter table student rename stu;

3.1向表中插入數據 然后查看表的信息

-- 向表中插入信息
insert into student(id, birthday, name, age, tel) values(1, "1997-7-3", "張三", 20, "17766074507");

3.2表中插入信息的幾種方式 有默認值的可以不寫值 以默認值自動插入

-- 向表中插入信息
insert into stu(id, birthday, name, age) values(2, "1997-7-3", "李四", 20);

-- 向表中插入信息
insert into stu values
(3, "1997-7-3", "李四2", 20, "17766074512"),
(4, "1997-7-3", "李四3", 20, "17766074532");

3.3刪除表中數據信息 條件可以自己想想

--刪除數據
delete from student where id = 3;

--刪除表
drop table xxxx;

總結

以上是生活随笔為你收集整理的mysql常用命令集合 及附图操作的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。