檢視資料庫
show databases;
進入切換資料庫
檢視表use 資料庫名
use crushlinux;
show tables;
新建資料庫,新建表
檢視表中字段create database 庫名;
create database yi;
create table 表名(欄位一,欄位2);
create table yi(name char(14) not null , password char(23) not null default '' ,primary key(name));
查詢desc 表名
desc yi;
插入資料select 字段 from 表名 where 條件;
select * from users;
更新資料insert into 表名(欄位一,欄位二...) values(值1,值2....)
insert into yi values('zhangsan','123');
刪除資料update 表名 set 字段=值 where 條件;
update yi
-> set
-> name='lisi'
-> where name='zhangsan'
-> ;
設定使用者許可權(使用者不存在是建立)delete from 表名 where 條件;
delete from yi where name = 'lisi';
重新整理授權表grant 命令 on 資料庫名.表名 to 使用者名稱@位址 identified by 『密碼』
grant all on *.* to user1@'192.168.200.1' identified by '123';
flush privileges;
檢視使用者許可權
撤銷使用者許可權show grants for root@位址
show grants for 'root'@localhost;
revoke 許可權列表 on 資料庫名.表名 from 使用者名稱@位址
顯示伺服器狀態資訊,許可權資訊
顯示當前時間show status
show grants
show now();
MySql 常用SQL語句
create database kali use kali show tables create table students sno varchar 10 primary key,sname varchar 10 not null,varchar 2 check in 男 女 age varcha...
常用sql語句(mysql)
給表新增列 sql alter table table name add column col name varchar 255 not null default default value 增加表列,指定格式 sql alter table table name add col name bool...
MySQL常用SQL語句
查詢一張表中的所有資料 sql view plain copy select from table name 查詢一張表中的指定列資料 sql view plain copy select column a,column b from table name 按條件查詢一張表中的所有資料 sql vi...