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


之前分享过多次Mysql主题,今天继续分享mysql命令行入门
 
1.
那么多mysql客户端工具,为何要分享命令行操作?
-快捷、简单、方便
-在没有客户端的情况下怎么办
-如果是mysql未开启第三方访问,客户端就是白瞎
 
2.
如何通过命令行进入mysql
 
--Start--
[root@localhost~]# mysql -u root -p    #老徐注释:输入左侧命令,回车 root是用户名

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

Welcome to the MySQL monitor.  Commands end with ; or g.

Your MySQL connection id is 10

Server version: 5.6.23-log Source distribution

 

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

 

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

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

 

mysql>      #老徐注释:如果看到如上信息代表已经进入mysql

--End--

 
 
3. 
如何查看数据库信息
 
--Start--
 

mysql> show databases;   #老徐注释:输入左侧命令,回车

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

| Database           |

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

| information_schema |

| mysql              |

| performance_schema |

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

3 rows in set (0.00 sec)

 

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

 
 
--End--
 
4.
使用某个数据库
查看当天库下有哪些表
 
--Start--
 

mysql> use mysql     #老徐注释:左侧,use 表名,使用某个表

Database changed

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

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

| Tables_in_mysql           |

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

| columns_priv              |

| db                        |

| event                     |

| func                      |

| general_log               |

| help_category             |

| help_keyword              |

| help_relation             |

| help_topic                |

| innodb_index_stats        |

| innodb_table_stats        |

| ndb_binlog_index          |

| plugin                    |

| proc                      |

| procs_priv                |

| proxies_priv              |

| servers                   |

| slave_master_info         |

| slave_relay_log_info      |

| slave_worker_info         |

| slow_log                  |

| tables_priv               |

| time_zone                 |

| time_zone_leap_second     |

| time_zone_name            |

| time_zone_transition      |

| time_zone_transition_type |

| user                      |

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

28 rows in set (0.00 sec)

 

mysql> 

 
 
--End--
 
5. 
剩下就是很简单的增删改查了
如:
select * from xx  where xx = xx
update xx set xx = xx where xx
delete
insert
等等
具体sql增删改查知识,自行百度,或者买个数据库书好好看
 
原文地址:https://www.cnblogs.com/idotest/p/5904199.html