【目錄】
一 系統資料庫
二 創建資料庫
三 資料庫相關操作
一 系統資料庫
查看語法:show databases;
information_schema: 虛擬庫,不占用磁盤空間,存盤的是資料庫啟動后的一些引數,如用戶表資訊、列資訊、權限資訊、字符資訊等
performance_schema: MySQL 5.5開始新增一個資料庫,主要用于收集資料庫服務器性能引數,記錄處理查詢請求時發生的各種事件、鎖等現象
mysql: 授權庫,主要存盤系統用戶的權限資訊
test: MySQL資料庫系統自動創建的測驗資料庫
二 創建資料庫
1 語法(create database)
# 方法一:
create database
資料庫名 charset utf8mb4;
# 方法二:先不鏈接mysql服務端,直接使用管理員身份建資料庫
C:\WINDOWS\system32>mysqladmin -u root -p create 資料庫名;
C:\WINDOWS\system32>mysqladmin -u root -p create db914; Enter password: *** C:\WINDOWS\system32>mysql -u root -p Enter password: *** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.6.48 MySQL Community Server (GPL) Copyright (c) 2000, 2020, 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | bms_info | | db907p | | db914; | | dbp1 | | mysql | | performance_schema | | test | +--------------------+ 8 rows in set (0.01 sec)View Code
2 資料庫命名規則:
可以由字母、數字、下劃線、@、#、$
區分大小寫
唯一性
不能使用關鍵字如 create select
不能單獨使用數字
最長128位
三 資料庫相關操作
1 查看資料庫 show databases; show create database 資料庫名; select database(); 2 選擇使用資料庫 use 資料庫名 3 洗掉資料庫 drop database 資料庫名; 4 修改資料庫(資料庫名是不能修改的,可以修改其編碼格式) alter database 資料庫名 charset utf8mb4; # 統一編碼格式后,就無需指定了![]()
![]()
使用管理員身份操作資料庫:
-洗掉資料庫--》mysqladmin -u root -p drop 資料庫名;
-創建資料庫(見上部分-創建資料庫)
參考:https://www.cnblogs.com/linhaifeng/articles/7211690.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/46553.html
標籤:MySQL




