How to create a simple mysql database

1. Create a database

Note: MySQL is already installed.

Run cmd under windows to enter the command window,

I am using the win7 system, first enter F: enter the F drive, and then enter "cd F:\mysql\mysql-5.7.18-winx64\bin" (Note: do not use quotation marks, the path is the path to decompress mysql by yourself).

Enter net start mysql to start the service, enter net stop mysql to stop the service,

After entering mysql -u root -p, you will be prompted to enter a password, enter the password and enter the mysql console.

2. Create a database

Enter create database student; create a database (student is the database name)

Use show databases; see which databases are available

Enter the use  student command and this will create a database table,

输入create table tb_stu1 (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(30) DEFAULT NULL,
  `sex` varchar(2) DEFAULT NULL,
  `birthday` date DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

Note: tb_stu1 bit table name


Use show tables to view the table name under test,

After building, use describe tb_stu1 ; view (Note: You must use use student to enter the database before you can use this command) 



Use INSERT INTO tb_stu1(id,name,sex,birthday) VALUES ( 1, 'Xiao Ming', 'Male', '2015-11-02'); join data,

Use select * from tb_stu1; to view the data


Use TRUNCATE TABLE  tb_stu1 ; clear data

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326501553&siteId=291194637