Linux-MySQL常用命令
阿新 • • 發佈:2018-12-05
注意:需要用分號作為命令結尾。
庫是由表組成的,表是由欄位組成的。
show databases; #檢視所有的資料庫
use mysql; #切換到另外一個庫,mysql為庫名,可以不用分號。
show tables; #檢視庫裡的表
desc tb_name; # 查看錶裡的欄位
show create table tb_name\G; #檢視建表語句。 \G 是指豎排,顯示,查看錶是怎麼建立的,包括字符集。
show create table tb_1\G;
select user(); #檢視當前使用者
select databsase(); #檢視當前使用的資料庫
create database db1; #建立一個叫db1的資料庫
drop table t1; #刪除t1表
use db1; #切換到db1的庫
create table t1(id
int(4), name
char(40)); #建立表名叫t1,定義第一個欄位叫id,第二個欄位叫name,定義字串,欄位用反引號。
select version(); #檢視當前資料庫版本
show status; #檢視資料庫狀態
檢視各引數 show variables;
show variables like 'max_connect_errors'; #檢視最大連線數
set global max_connect_errors=1000; #修改最大連線數
配置檔案修改:
show processlist; #檢視佇列
show full processlist;