IDO老徐,在深圳,某上市公司质量部负责人,干了十二年软件测试,公号"简尚" ,博客isTester.com ,关注「软件测试从业者综合能力提升」,微信957863300

mysql 命令行操作入门(详细讲解版)

上一篇 / 下一篇  2016-02-29 13:46:54 / 个人分类:数据库DB

51Testing软件测试网4mM7v'w!l

:~$U@od6V9Uf:l0
老徐之前博客写过一次,如何通过命令行导入脚本http://www.51testing.com/index.php?uid-497177-action-viewspace-itemid-3705449
很多同学比较感兴趣

XQ:|.N;j6S\-Bw!l0
--
51Testing软件测试网)o/oq'[T
今天继续分享,mysql命令行入门

Baz,P ]8t]b"j0
1.
那么多mysql客户端工具,为何要分享命令行操作?
-快捷、简单、方便
-在没有客户端的情况下怎么办
-如果是mysql未开启第三方访问,客户端就是白瞎

;D#F_,Bw&s0
2.
如何通过命令行进入mysql

Y!b5g!E\ u0
--Start--
[root@localhost~]# mysql -u root -p    #老徐注释:输入左侧命令,回车 root是用户名

Enter password:                         #老徐注释:输入密码

K\k;x-ppc Z0

Welcome to the MySQL monitor.  Commands end with ; or \g.51Testing软件测试网Cs*b/j7o^,W{ h4RO

Your MySQL connection id is 10

.DH(F Y`5\?0

Server version: 5.6.23-log Source distribution51Testing软件测试网&X\(G(T {1Pg

51Testing软件测试网'o bmi!z{

E^2DJ7o0

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.51Testing软件测试网8~/VW3[i


)S&G z\2Q d}0
51Testing软件测试网I3i-PZ `.N/O[4_

Oracle is a registered trademark of Oracle Corporation and/or its

`~^:y^%YM0

affiliates. Other names may be trademarks of their respective

y*[ ~Zu$o"b0

owners.51Testing软件测试网/q-A9b,F$x0K'e;};`


AW&Y2rvy0
51Testing软件测试网W$B8?!rZ A8|

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.51Testing软件测试网yf-i_-gs


r(lLp@"W0
51Testing软件测试网BhU+H:l9SNV

mysql>      #老徐注释:如果看到如上信息代表已经进入mysql51Testing软件测试网SSG.H%v_

--End--
51Testing软件测试网8]5Ih.x~L

g-l9YN%w q0
3. 
如何查看数据库信息
51Testing软件测试网8FN1LA Q&X:Y+r)j
--Start--

h0[ F1]/h+?r;W0

mysql> show databases;   #老徐注释:输入左侧命令,回车51Testing软件测试网;W1| k8w0Hr b L

+--------------------+

}6y2x-H)z&^0

| Database           |51Testing软件测试网r&C/E^u&JC.f

+--------------------+

1CJKE8N#K;_0

| information_schema |51Testing软件测试网3k` vim Q

| mysql              |51Testing软件测试网2xs Y)? q!o

| performance_schema |51Testing软件测试网8D] _.ZS.K6Fvl

+--------------------+51Testing软件测试网S(w3Q@&n~5x t

3 rows in set (0.00 sec)51Testing软件测试网2N`5Zrk q H


j[%s JfR6e@0
51Testing软件测试网Z(J:}6EH T:d

mysql>     #老徐注释:如上就是显示当前存在的数据库

sj5j}J M5n9^0

51Testing软件测试网5S-v o/ImWy"f

51Testing软件测试网bdu%Z!{"QQt
--End--

npRt#lzu0
4.
使用某个数据库
查看当天库下有哪些表

{K-C5[5U3S0
--Start--

+j5s{-?JaSY0

mysql> use mysql     #老徐注释:左侧,use 表名,使用某个表51Testing软件测试网s z-~w K(T

Database changed51Testing软件测试网SV7QPs N2Bqb1a

mysql> show tables;  #老徐注释:显示当前数据库下的所有表名51Testing软件测试网/Z0_ d U*M4?K

+---------------------------+

D.W\$Z%{2I0

| Tables_in_mysql           |

V/L z%]s2k)X0

+---------------------------+

/P\C{vj@QS-M0

| columns_priv              |51Testing软件测试网 N_!sl\N

| db                        |

p,K&Y};MA7N0

| event                     |51Testing软件测试网^pp]3K2im

| func                      |51Testing软件测试网7M`/a @D w_nh

| general_log               |51Testing软件测试网1_+J d8}c*|PGb

| help_category             |

F v5{ ]BS+S\0

| help_keyword              |51Testing软件测试网[&lD;E[N0a

| help_relation             |51Testing软件测试网eh;Al?w%Ud

| help_topic                |

*u o3D!It0

| innodb_index_stats        |51Testing软件测试网c ^xG*il H(`

| innodb_table_stats        |51Testing软件测试网(`j7^ GVjr

| ndb_binlog_index          |51Testing软件测试网 b0zae)~&W

| plugin                    |51Testing软件测试网 aF _bq/a

| proc                      |51Testing软件测试网p8Zv)S j?,B&Y.gr7\

| procs_priv                |51Testing软件测试网9g"HlmeFl

| proxies_priv              |51Testing软件测试网*F1t*WZK3Fy

| servers                   |51Testing软件测试网t$D+Lr!S0T

| slave_master_info         |51Testing软件测试网 JxbV'J

| slave_relay_log_info      |51Testing软件测试网/gm z,G7q+L

| slave_worker_info         |51Testing软件测试网 KD1C O:i

| slow_log                  |

$DRrC,P5QwS0

| tables_priv               |

8is a'GR1aK1T0

| time_zone                 |

u ND9@"[0

| time_zone_leap_second     |

i'm#i,kZQ%E0

| time_zone_name            |51Testing软件测试网L xi t v^

| time_zone_transition      |51Testing软件测试网 Y/?2]if1w

| time_zone_transition_type |

iA{h `'ja[ K0

| user                      |51Testing软件测试网*MM5^DY,k'P7b s

+---------------------------+

y$_9V8N,_ZY'_|6S0

28 rows in set (0.00 sec)

{SR1UO1}Vv-Q0

51Testing软件测试网:mn/ou.yl T] m

:e#p3KXc9pC+?1` Uy0

mysql> 

:}&Q;h;p.Y@0

51Testing软件测试网-]wX3p*glAH;c

51Testing软件测试网,Po+H*W\1Q2v1e
--End--
51Testing软件测试网6Z1]X&ZN&e
5. 
剩下就是很简单的增删改查了
如:
select * from xx  where xx = xx
update xx set xx = xx where xx
delete
insert
等等
具体sql增删改查知识,自行百度,或者买个数据库书好好看
51Testing软件测试网j kgz'u7h
51Testing软件测试网g _'AlR
--写在最后--
如果你想实时与老徐交流你的观点,分享你的经验,向老徐咨询你的各种问题
加《软件测试:邀你同行》(339611752)与老徐实时交流
分享、成长、收获!

以上文章老徐原创,未经允许勿转载!
老徐博客更多原创文章http://www.51testing.com/?497177


51Testing软件测试网]M.|;B oa

TAG: MySQL mysql mysql基本命令 mysql入门 软件测试必备

fhhh_eyou的个人空间 引用 删除 fhhh_eyou   /   2018-04-11 19:21:52
引用 删除 baoxiaoxia0   /   2016-03-01 09:59:30
5
 

评分:0

我来说两句

xuquan

xuquan

IDO老徐,坐标深圳,测试经理,干了十年测试,公号"简尚" ,个人博客isTester.com ,关注「软件测试从业者综合能力提升」,微信957863300

日历

« 2024-04-25  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 914604
  • 日志数: 427
  • 建立时间: 2012-06-04
  • 更新时间: 2022-02-23

RSS订阅

Open Toolbar