To create the database syntax:
[email protected]:~$ mysql-uxlong-pqwe123 #使用普通用户登录Mysqlmysql: [Warning] Using a password on the command Li Ne interface can be insecure. Welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 14Server version:5.7.21-0ubuntu0.16.04.1 (Ubuntu) Copyright (c), 2018, Oracle and/o R 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 ' for help. Type ' \c ' to clear the current input statement.mysql> create database mybd1; #创建一个名为 "MYDB1" database query OK, 1 row Affected (0.00 sec) mysql> Show databases; #查看创建的数据库 "MYDB1" +--------------------+| Database |+--------------------+| Information_schema | | MYBD1 | | MySQL | | Performance_schema | | SYS |+--------------------+5 rows in Set (0.00 sec) mysql> drop database mybd1; #删除名为 the database "MYDB1", you can also use thisSample syntax Delete database (drop db if exists mydb1;) Query OK, 0 rows Affected (0.00 sec) mysql> Show databases; #查看删除结果, the "MYDB1" database has been deleted +--------------------+| Database |+--------------------+| Information_schema | | MySQL | | Performance_schema | | SYS |+--------------------+4 rows in Set (0.00 sec) mysql> SELECT DATABASE (); #查看当前在数据库的目录, like the PWD in Linux. +------------+ #这个结果表示, currently just inside the MySQL lobby, has not entered the database. DATABASE () |+------------+| NULL |+------------+1 row in Set (0.01 sec)
Enter the database:
mysql> CREATE database mydb123; #创建一个数据库Query OK, 1 row Affected (0.00 sec) mysql> show databases; #查看创建结果, Mydb123 has created complete +--------------------+| Database |+--------------------+| information_schema | | mydb123 | | mysql | | performance_schema | | sys |+--------------------+5 rows in Set (0.00 sec) mysql> use mydb123; #进入创建的mydb123 database changedmysql> Select db (); #查看当前所在数据库目录, the mydb123 database has been entered. +------------+| Database () |+------------+| Mydb123
Mysql database creation and deletion (base 2)