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常用命令集合 及附图操作的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 8-13 刷题 复习 知识点集合
- 下一篇: mysql 怎么在VS2017上附加进去