Basic Introduction to MySQL database commands

Source: Internet
Author: User
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 MySQL basic information: MySQLstatus; view variable: showvariableslike % ver

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 MySQL basic information: MySQL status; view variable: showvariableslike '% ver

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:

 
 
  1. MySQL>status;

View variables:

 
 
  1. 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:

 
 
  1. 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

 
 
  1. 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

 
 
  1. show databases;

Create a new database

 
 
  1. create database new;
  2. drop database if exists school;

If SCHOOL exists, delete it.

Use this database

 
 
  1. use new;

MySQL database command: Create a new table

 
 
  1. create table app_user(
  2. username varchar(20),
  3. password varchar(255),
  4. primary key(username));

Display table structure

 
 
  1. describe app_user;/desc app_user;

Show all tables

 
 
  1. show tables;

Insert Test Data

 
 
  1. insert into app_user values('tomcat' , '123');
  2. insert into app_user values('yeeku' , '123');

Exit MySQL Management Interface

 
 
  1. exit/quit;

The above content is an introduction to the basics of the MySQL database. I hope you will have some gains.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.