Login into the terminal:
mysql -u root -p
display database
SHOW DATABASES;
Create a database:
CREATE DATABASE IF NOT EXISTS RUNOOB_TEST DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
- 1. If the database does not exist, it will be created, if it exists, it will not be created.
- 2. Create the RUNOOB_TEST database and set the encoding set to utf8
Created successfully:
Delete the database:
DROP DATABASE test
Select a database:
use runoob_test;
Create a data table:
CREATE TABLE IF NOT EXISTS `runoob_tbl`( `runoob_id` INT UNSIGNED AUTO_INCREMENT, `runoob_title` VARCHAR(100) NOT NULL, `runoob_author` VARCHAR(40) NOT NULL, `submission_date` DATE, PRIMARY KEY ( `runoob_id` ) )ENGINE=InnoDB DEFAULT CHARSET=utf8;
Created successfully:
View table:
SHOW TABLES;
drop table:
DROP TABLE test2;
When you check again, there is no test2 table.
Insert data:
Insert succeeded:
Welcome to exchange and correct, follow me, and learn together.
Reference link:
MySQL Create Database | Novice Tutorial
create database xx or show database does not respond - Weixin_33785108's Blog - CSDN Blog