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

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

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

51Testing软件测试网4ws0v ofO tI

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

sgj,|%o/t'i0
--
51Testing软件测试网Q/q R js%^
今天继续分享,mysql命令行入门

'JZ o%? _M0
1.
那么多mysql客户端工具,为何要分享命令行操作?
-快捷、简单、方便
-在没有客户端的情况下怎么办
-如果是mysql未开启第三方访问,客户端就是白瞎
51Testing软件测试网EVk%q\\i;M
2.
如何通过命令行进入mysql
51Testing软件测试网 g fmlf
--Start--
[root@localhost~]# mysql -u root -p    #老徐注释:输入左侧命令,回车 root是用户名

Enter password:                         #老徐注释:输入密码51Testing软件测试网C(I%iT,\8j`

Welcome to the MySQL monitor.  Commands end with ; or \g.51Testing软件测试网3Ul6I-a,QE

Your MySQL connection id is 1051Testing软件测试网x&jVHL

Server version: 5.6.23-log Source distribution51Testing软件测试网Q,R] a Sv:N)h

51Testing软件测试网&pB0g/W l

"{VV T!K9l k)t0

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

.FAM} nB[~0


:~aaz7oV0{m[,?0
51Testing软件测试网:E%o\x `

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

`"C.x1B]E7Q+H0

affiliates. Other names may be trademarks of their respective

Ev:M(s8eX-Z0

owners.

$T3yTroi;E#P0


*A.TJ1MQ"G/U R0

t4X}}j8w1ZU]0

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.51Testing软件测试网H(d9uR1KA V

51Testing软件测试网m4J4].s)Lq-\._0keR

Pt }3I[ Y0

mysql>      #老徐注释:如果看到如上信息代表已经进入mysql51Testing软件测试网3Y-I3MC4a2OJf

--End--

;a/DR.MUxQ0

i` M\h ]2b+E y0
3. 
如何查看数据库信息
51Testing软件测试网|1?;O&VTz'G
--Start--
51Testing软件测试网/p L CrAN*X$T0y2z

mysql> show databases;   #老徐注释:输入左侧命令,回车51Testing软件测试网0X0P/fll cD

+--------------------+51Testing软件测试网xfgE2Z tNH0s$eN

| Database           |

[&Z%W(U0MD0

+--------------------+51Testing软件测试网A].] dez8\ k`;Id

| information_schema |

&UQ+@&[GD[0

| mysql              |51Testing软件测试网(`h;Gd J;?6Xx-p

| performance_schema |

E:^c(X0T K7H0

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

vj5H w(GL#n0

3 rows in set (0.00 sec)

2K k oq9a1Sqs1c0


Y^PnPd9z0

+Tzi S'JY B_t n2X;?0

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

X.q'f CO"J:a4A0

4K6Mp/` { U+Y0
51Testing软件测试网[Q5q^^ k
--End--

~0sj;SI"_U1T0
4.
使用某个数据库
查看当天库下有哪些表

{OvI_5i(Y/`9Yf0
--Start--

4H9fpR\1c~5i"[ o y0

mysql> use mysql     #老徐注释:左侧,use 表名,使用某个表51Testing软件测试网A5V9E/} gd!dJOWL

Database changed51Testing软件测试网d:T`A?,?T_

mysql> show tables;  #老徐注释:显示当前数据库下的所有表名

O\h T1Ke*x0

+---------------------------+51Testing软件测试网f(QGsb/Fp"h

| Tables_in_mysql           |

:{X$@#TY\o@0

+---------------------------+51Testing软件测试网 z'P(km}1T_

| columns_priv              |

FjU]'^ m,U YNa0

| db                        |

!^~!OIT/nz7sA0

| event                     |51Testing软件测试网 RJ7\a/t yL1tS

| func                      |

AgI,P_~6A0

| general_log               |51Testing软件测试网 q&S'w.l]5x

| help_category             |51Testing软件测试网3e&I!nd3_:v.dAX/U6K

| help_keyword              |51Testing软件测试网MP&UH$wHoF

| help_relation             |51Testing软件测试网tE\"[0I3Yo

| help_topic                |

f9SVrC0J0

| innodb_index_stats        |51Testing软件测试网[ `$F Op X

| innodb_table_stats        |

y,K{*|q0

| ndb_binlog_index          |

9_ MyYq(K6k d1C!f n0

| plugin                    |

4M}'_&[6Z k0

| proc                      |

R"y2sk+O%{X0

| procs_priv                |51Testing软件测试网@%\2zxN

| proxies_priv              |

r3vk)h.] m2eL0

| servers                   |51Testing软件测试网W/l4fUa {

| slave_master_info         |51Testing软件测试网u,{2D1D:b

| slave_relay_log_info      |51Testing软件测试网.Cp:Wy7?

| slave_worker_info         |51Testing软件测试网,X'vEo7J@m

| slow_log                  |51Testing软件测试网dRkfH*P

| tables_priv               |

BxY(z7x,Fx0

| time_zone                 |

6q$GfZcZK t8Vp0

| time_zone_leap_second     |

? T4?2kw0

| time_zone_name            |51Testing软件测试网VH5Cl k6@W

| time_zone_transition      |

,M:o T&L"c z%U0

| time_zone_transition_type |

H.t]%QBH0

| user                      |51Testing软件测试网 y^2C'L biP#M

+---------------------------+51Testing软件测试网 fx_t Tk/AI

28 rows in set (0.00 sec)51Testing软件测试网#iy!_uc _i7S

51Testing软件测试网rulf5kk*b

\^+v'b*d7Ja4O x7}%B0

mysql> 51Testing软件测试网$M%n%x1UWLD$|

N-[y u&`aG)X~0

I1GY Ms0
--End--

| p7@6Bd0
5. 
剩下就是很简单的增删改查了
如:
select * from xx  where xx = xx
update xx set xx = xx where xx
delete
insert
等等
具体sql增删改查知识,自行百度,或者买个数据库书好好看
51Testing软件测试网#s:T P0g{!^cQ

FA2{+O7^iT0
--写在最后--
如果你想实时与老徐交流你的观点,分享你的经验,向老徐咨询你的各种问题
加《软件测试:邀你同行》(339611752)与老徐实时交流
分享、成长、收获!

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



JZVR;{(?D4D?"h0

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-05-05  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

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

RSS订阅

Open Toolbar