1. System database
After installing the database system, the system comes with a database. After connecting to the database system through the mysql client, use the show command to view all the libraries that exist in the system:
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | course | | course_db | | db1 | | education | | mysql | | performance_schema | | sakila | | school | | shop | | student | | test | | world | +--------------------+ 13 rows in set (0.00 sec)
The source and role of each library:
information_schema: The virtual library does not occupy disk space, and stores some parameters after the database is started, such as user table information, column information, permission information, character information, etc.; performance_schema: MySQL 5.5 starts to add a new database: mainly used to collect database server performance parameters, record various events, locks and other phenomena that occur when processing query requests; mysql: Authorization library, which mainly stores the permission information of system users; test: A test database automatically created by the MySQL database system; Except for the libraries mentioned above, the rest are user-defined libraries.
2. Library operation
1. Create a library
1) Basic grammar
create database 库名 charset utf8;
2) Library name naming convention
Naming rules: A. The library name can be composed of letters, numbers, underscores, @, # , $; B. The letters are case-sensitive; C. The library name is unique and cannot be created repeatedly; D. Prohibit the use of keyword naming; E. It is forbidden to use number names alone; F. The maximum length of the name is 128 characters
3) Basic operations
Create the library, and specify the character encoding:
create database db1 charset utf8;
Change library information:
alter database db1 charset gbk;
Remove the library:
drop database db1;
View database information:
View all library names:
show databases;
View the specified library information:
show create database db1;
View the current library:
select database();