??
show databases;
use 數(shù)據(jù)庫名;
show tables;
describe 表名;
SELECT * FROM 表名
create databse 庫名;
create table 表名 (字段設(shè)定列表); mysql> create table name( -> id int auto_increment not null primary key , -> uname char(8), -> gender char(2), -> birthday date ); Query OK, 0 rows affected (0.03 sec) mysql> show tables; +------------------+ | Tables_in_userdb | +------------------+ | name | +------------------+ 1 row in set (0.00 sec) mysql> describe name; +----------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+---------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | uname | char(8) | YES | | NULL | | | gender | char(2) | YES | | NULL | | | birthday | date | YES | | NULL | | +----------+---------+------+-----+---------+----------------+ 4 rows in set (0.00 sec) 注: auto_increment 自增 primary key 主鍵
insert into name(uname,gender,birthday) values('張三','男','1971-10-01');
update name set birthday='1971-01-10' where uname='張三';
delete from name where uname='張三';
drop table 表名
drop database 庫名;
mysqldump -u root -p --opt 數(shù)據(jù)庫名>備份名; //進(jìn)入到庫目錄
mysql -u root -p 數(shù)據(jù)庫名<備份名; //恢復(fù)時(shí)數(shù)據(jù)庫必須存在,可以為空數(shù)據(jù)庫
格式:grant select on 數(shù)據(jù)庫.* to 用戶名@登錄主機(jī) identified by "密碼"
例1、增加一個(gè)用戶user001密碼為123456,讓他可以在任何主機(jī)上登錄,并對所有數(shù)據(jù)庫有查詢、插入、修改、刪除的權(quán)限。首先用以root用戶連入MySQL,然后鍵入以下命令:
上一個(gè)教程:SecureCRT常用Linux命令
下一個(gè)教程:Linux服務(wù)器配置、環(huán)境搭建常用命令行