Linux终端操作MySQL常用命令
1.終端啟動 MySQL:/etc/init.d/mysql start
2.登錄 MySQL:mysql -uroot -p (用 root 賬戶登錄),然后輸入密碼?
3.查看所有的數(shù)據(jù)庫名字:show databases;?
4.選擇一個數(shù)據(jù)庫操作: use database_name;?
5.查看當(dāng)前數(shù)據(jù)庫下所有的表名:show tables;?
6.創(chuàng)建一個數(shù)據(jù)庫:create database database_name;?
7.刪除一個數(shù)據(jù)庫:drop database database_name;?
8.創(chuàng)建一個表: create table mytest( uid bigint(20) not null primary key, uname varchar(20) not null);?
9.刪除一個表: drop table mytest;?
10.SQL 插入語句:insert into table_name(col1,col2) values(value1,value2);?
11.SQL 更新語句:update table_name set col1='value1',col2='value2' where where_definition;?
12.SQL 查詢語句:select * from table_name where.......
13.SQL 刪除語句:delete from table_name where...?
14.增加表結(jié)構(gòu)的字段:alert table table_name add column field1 date ,add column field2 time...?
15.刪除表結(jié)構(gòu)的字段:alert table table_name drop field1;?
16.查看表的結(jié)構(gòu):show columns from table_name;?
17.limit 的使用:select * from table_name limit 3; ? //每頁只顯示 3 行?
select * from table_name limit 3,4; ? //從查詢結(jié)果的第三個開始,顯示四項結(jié)果。 此處可很好的用來作分頁處理。?
18.對查詢結(jié)果進(jìn)行排序: select * from table_name order by field1,orderby field2;多重排序?
19.退出 MySQL:exit;?
20.刪除表中所有數(shù)據(jù): truncate table 數(shù)據(jù)表名稱 (不可恢復(fù))
轉(zhuǎn)載于:https://www.cnblogs.com/jeasonit/p/9722329.html
總結(jié)
以上是生活随笔為你收集整理的Linux终端操作MySQL常用命令的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 必做作业2:目前比较火的直播软件调研
- 下一篇: 在Asp.net core 项目中操作M