提示:当多行命令输入,发现错误后,用\c结束。以RUNOOB为数据库名、runoob_tbl为数据库表名
菜鸟教程:https://www.runoob.com/mysql/mysql-order-by.html
登陆数据库 : mysql -u root -p
创建数据库(RUNOOB): mysql> create DATABASE RUNOOB;
drop 命令删除数据库(RUNOOB):mysql> drop database RUNOOB;
mysqladmin 删除数据库(RUNOOB):[root@host]# mysqladmin -u root -p drop RUNOOB
选择数据库:mysql> use RUNOOB;
创建数据表(在 RUNOOB 数据库中创建数据表runoob_tbl):CREATE TABLE table_name (column_name column_type);
CREATE TABLE IF NOT EXISTS `runoob_tbl`(
`runoob_id` INT UNSIGNED AUTO_INCREMENT,
`runoob_title` VARCHAR(100) NOT NULL,
`runoob_author` VARCHAR(40) NOT NULL,
`submission_date` DATE,
PRIMARY KEY ( `runoob_id` )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
查看数据库中的表: show tables;
查看表结构: desc table_name;
删除数据表:mysql> DROP TABLE runoob_tbl
查询数据库连接
状态:
show
full
processlist;
show status
like
'%Max_used_connections%'
;
show status
like
'%Threads_connected%'
;#当前连接数
show status
like
'%table_lock%'
;#表锁定
show status
like
'innodb_row_lock%'
;#行锁定
show status
like
'%qcache%'
; #查询缓存情况
show variables
like
"%query_cache%"
;
SHOW STATUS
LIKE
'Qcache%'
;
show variables
like
"%binlog%"
;
show status
like
'Aborted_clients'
;#由于客户没有正确关闭连接已经死掉,已经放弃的连接数量
show variables
like
'%max_connections%'
;//查看最大连接数量
show variables
like
'%timeout%'
;#查看超时时间
show variables
like
'log_%'
; #查看日志是否启动