目錄
1,登陸 MySQL 服務
[root@raspberrypi ~]$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 73
Server version: 10.3.22-MariaDB-0+deb10u1 Raspbian 10
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
2,數據庫的創建
語法:CREATE DATABASE [IF NOT EXISTS] mydb1 [CHARSET=utf8]
- 創建一個名爲mydb的數據庫:
MariaDB [(none)]> create database mydb;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]>
3,查看數據庫
show databases;
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mydb |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.001 sec)
MariaDB [(none)]>
4,使用數據庫
use <數據庫名>;
MariaDB [(none)]> use mydb;
Database changed
MariaDB [mydb]>
5,刪除數據庫
drop database <數據庫名>;
MariaDB [mydb]> drop database mydb;
Query OK, 0 rows affected (0.002 sec)
MariaDB [(none)]>
參考:https://www.runoob.com/mysql/mysql-create-database.html