1. The show command, which provides information about a database, table, field, or server state, such as displaying a database
Mysql> show databases; +--------------------+| Database |+--------------------+| information_schema | | mysql | | performance_schema | | Test | | yuanqk | | | YUANQK_GBK | | Yuanqk_utf8 |+--------------------+7 in Set (0.00 sec) MySQL
Yuanqk, Yuanqk_gbk\utf8 is the database I just created, to the operating system to see what has been created, my data storage directory under the/data/3306/data
[Email protected] data]# pwd
/data/3306/data
[Email protected] data]# LS-LRT
Total 141336
DRWX------. 2 MySQL mysql 4096 may 23:32 test
DRWX------. 2 MySQL mysql 4096 may 23:32 Performance_schema
DRWX------. 2 MySQL mysql 4096 may 23:32 MySQL
-RW-RW----. 1 MySQL MySQL 5242880 may 23:35 ib_logfile1
-RW-RW----. 1 mysql mysql 134217728 19:38 ibdata1
-RW-RW----. 1 MySQL MySQL 5242880 may 10:40 ib_logfile0
DRWX------. 2 mysql mysql 4096 10:53 yuanqk <=== corresponding three directories
DRWX------. 2 mysql mysql 4096 10:58 yuanqk_gbk <=== corresponding three directories
DRWX------. 2 mysql mysql 4096 11:03 yuanqk_utf8 <=== corresponding three directories
[Email protected] data]# CD YUANQK
[Email protected] yuanqk]# ls-l
Total 4
-RW-RW----. 1 mysql mysql 10:53 db.opt <=== This is supposed to be a data file.
[Email protected] yuanqk]# CD. /yuanqk_gbk/
[Email protected] yuanqk_gbk]# ls-l
Total 4
-RW-RW----. 1 MySQL MySQL 10:58 db.opt
[Email protected] yuanqk_gbk]#
What tables are----------------displayed------------
Mysql> Show tables;
Empty Set (0.00 sec) <=== display is blank because it is not connected to the database, but you can use the from or in keyword to display information from other databases
Mysql> show tables from MySQL;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_cat Egory |
| help_keyword |
| help_relation |
| help_topic |
| host |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| servers |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
rows in Set (0.00 sec)
Mysql>
Mysql>
Mysql> show tables in MySQL;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| Columns_priv |
| db |
| Event |
| Func |
| General_log |
| Help_category |
| Help_keyword |
| help_relation |
| Help_topic |
| Host |
| Ndb_binlog_index |
| Plugin |
| Proc |
| Procs_priv |
| Proxies_priv |
| Servers |
| Slow_log |
| Tables_priv |
| Time_zone |
| Time_zone_leap_second |
| Time_zone_name |
| time_zone_transition |
| Time_zone_transition_type |
| user |
+---------------------------+
Rows in Set (0.00 sec)
Mysql>
You can also connect to the database using use, and then use the show command, show has a lot of commands that can be viewed through Help show
2, connect the database, this simple, is to use database, this is the same as SQL Server
Select database (); <=== look at the current database in which the display is null+------------+| Database () |+------------+| NULL |+------------+1 in Set (0.00 sec)
--Connect a random
Mysql> Use Yuanqk
Database changed
Mysql> Select Database ();
+------------+
| Database () |
+------------+
| Yuanqk |
+------------+
1 row in Set (0.00 sec)
Mysql> Use YUANQK_GBK
Database changed
Mysql> Select Database ();
+------------+
| Database () |
+------------+
| YUANQK_GBK |
+------------+
1 row in Set (0.00 sec)
Mysql>
3, delete the database, this is also very simple, drop databases dbname
Well, there's a test database on it, it looks awkward, delete mysql > drop Database test; Query OK, 0 rows affected (0.09 sec) MySQL > show databases; <=== has not seen test through the show command +--------------------+| Database |+--------------------+| Information_schema | | MySQL | | Performance_schema | | Yuanqk | | YUANQK_GBK | | Yuanqk_utf8 |+--------------------+6 rows in
Set (0.00 sec) MySQL >
---- -See what's changed on the operating system----------
[Email protected] yuanqk_gbk]# CD. /
[Email protected] data]# LS-LRT
Total 141332
DRWX------. 2 MySQL mysql 4096 may 23:32 Performance_schema <===== The entire directory is gone, if there is no backup, estimated to run overnight
DRWX------. 2 MySQL mysql 4096 may 23:32 MySQL
-RW-RW----. 1 MySQL MySQL 5242880 may 23:35 ib_logfile1
DRWX------. 2 MySQL mysql 4096 may 10:53 yuanqk
DRWX------. 2 MySQL mysql 4096 may 10:58 YUANQK_GBK
DRWX------. 2 MySQL mysql 4096 may 11:03 Yuanqk_utf8
-RW-RW----. 1 MySQL MySQL 134217728 may 12:17 ibdata1
-RW-RW----. 1 MySQL MySQL 5242880 may 12:17 ib_logfile0
[Email protected] data]#
4, function correlation, database () is a function, and the following, I only know these 4, or just learned.
Mysql>Selectversion ();+------------+| Version () |+------------+|5.5. --log |+------------+1RowinchSet (0.00sec) MySQL>Selectuser ();+----------------+| User () |+----------------+| [Email protected] |+----------------+1RowinchSet (0.00sec) MySQL>SelectNow ();+---------------------+| Now () |+---------------------+|2018- to- + A: -: -|+---------------------+1RowinchSet (0.04sec) MySQL>
5, just logged in the database was not careful more than a space, but let me master a method of login, earned ....
[Email protected] mysql]# mysql-uroot-p yuanqk-s/data/3306/mysql.sock <===-P and Yuanqk between the accidentally knocked a space, originally-pyuanqk is to represent the password of the root of the enter password:welcome to the MySQL monitor. Commands End With; or \g.your MySQL connectionIDIs4Server Version:5.5. --log MySQL Community Server (GPL) Copyright (c) -,2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or Itsaffiliates. Other names trademarks of their respectiveowners. Type'Help ;'Or'\h' forHelp. Type'\c'ToClearThe current input statement.mysql> <=== after a series of operations, when using Select Database (), it was discovered unexpectedly, when did I connect to the YUANQK library? So, found a space above the problem, so I mastered a direct connection to the MySQL database method .....
Mysql> Select Database ();
+------------+
| Database () |
+------------+
| Yuanqk |
+------------+
1 row in Set (0.00 sec)
Mysql> exit
Bye
[[email protected] mysql]# mysql-uroot-pyuanqk yuanqk-s/data/3306/mysql.sock <=== Connection Yuanqk Database
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 6
Server Version:5.5.60-log MySQL Community Server (GPL)
Copyright (c), 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Mysql> Select Database ();
+------------+
| Database () |
+------------+
| Yuanqk |
+------------+
1 row in Set (0.00 sec)
Mysql> exit
Bye
[[email protected] mysql]# mysql-uroot-pyuanqk yuanqk_gbk-s/data/3306/mysql.sock <=== Connection YUANQK_GBK Database
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 7
Server Version:5.5.60-log MySQL Community Server (GPL)
Copyright (c), 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Mysql> Select Database ();
+------------+
| Database () |
+------------+
| YUANQK_GBK |
+------------+
1 row in Set (0.00 sec)
Mysql>
Simple connection, delete database and show commands