Creation and operation of MySQL database and data table

Creation and operation of MySQL database and data table


1. Log in to MySQL

cd /usr/local/mysql/bin
mysql -u root -p

At this time, it will pop up to enter the password, and then you can log in.

2. View the current database

show databases;

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-brggewGt-1611113698246)(evernotecid://6FE75482-54A0-433A-9625-A01F7FEE92EC/appyinxiangcom/9896050/ENResource /p3121)]

3. Create a database

create database budaye_test01 default character set utf8;

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-KXXVw0e9-1611113698248)(evernotecid://6FE75482-54A0-433A-9625-A01F7FEE92EC/appyinxiangcom/9896050/ENResource /p3122)]

4. Use the newly created database

use budaye_test01

5. Query the created table

show tables;

6. Create database tables

create table now_list(
 
id int primary key auto_increment,
 
name varchar(50),
 
age int
 
);

7. Query table content

select *from name_table;

8. Delete database tables

DROP TABLE now_tasks;

9. MySQL exit

There are three ways to exit mysql:

  • mysql > exit;
  • mysql > quit;
  • mysql > \q;

PS: For more more content..., please check --> "Server Development"
PS: More more content..., please check --> "Server Development"
PS: More more content..., please check --> "Server Development"

Guess you like

Origin blog.csdn.net/u011578734/article/details/112861161