The following articles mainly describe MySQL database commands in detail. We first begin by displaying the basic information of the MySQL database to parse the MySQL database commands in detail, the following describes the specific content of the article.
Display basic MySQL information:
- MySQL>status;
View variables:
- show variables like '%version%';
Backup and Restore MySQL database command:
1. Command for backing up MySQL database:
Run the following command in the lib directory of MySQL in cmd:
- MySQLdump -hhostname -uusername -ppassword databaseName > backupfile.sql
Example:
MySQLdump-hlocalhost-uroot-p123456 test> test. SQL
2. Export a table:
MySQLdump-u user name-p database name Table Name> exported file name
- MySQLdump -u root -p dataname users> dataname_users.sql
Command to restore the MySQL database of the MySQL database:
First, create a database: create database;
Then enter the database: use Database Name;
Then execute the SQL Script: MySQL> source d: \ aaa. SQL;
Complete
MySQL Database help Command: Enter MySQLdump-help in the lib directory
NOTE: If environment variables are configured, you can directly run them without entering lib.
Connect to MySQL
Run mysqld.exe in the mysqlinstallation directory to start the service.
Go to the MySQL Management page
MySQL-h localhost-u root-p
-H host name-u user name-p Password
Change the password.
Format: MySQLadmin-u username-p old password New password
MySQLadmin-u root-password ab12
Note: because the root account does not have a password at the beginning, the old-p password can be omitted.
Change the root password to 123456.
Show all databases
- show databases;
Create a new database
- create database new;
- drop database if exists school;
If SCHOOL exists, delete it.
Use this database
- use new;
MySQL database command: Create a new table
- create table app_user(
- username varchar(20),
- password varchar(255),
- primary key(username));
Display table structure
- describe app_user;/desc app_user;
Show all tables
- show tables;
Insert Test Data
- insert into app_user values('tomcat' , '123');
- insert into app_user values('yeeku' , '123');
Exit MySQL Management Interface
- exit/quit;
The above content is an introduction to the basics of the MySQL database. I hope you will have some gains.