MySQL Common command collection

Source: Internet
Author: User

Reprinted from: http://www.educity.cn/wenda/400530.html

1. Link MySQL database

Format: mysql-h domain-u user name-p password database name

1.1 First open the DOS window, then enter the directory Mysql\bin, and then type the command mysql-uroot-p, Enter the password after you are prompted to lose. Note The user name can have a space or no space, if just installed MySQL, no password, superuser root is no password, so directly enter into MySQL, MySQL prompt is: mysql>

1.2 Exit MySQL command: Exit

2. Change the password   

Format: Mysqladmin-u username-P Old password password new password

3. Displays the list of databases in the current database server:

mysql> show databases;

4. Display the data tables in the database:

mysql> use database name;

Mysql> Show tables;

5. Display the structure of the data table:

mysql> describe table name;

6. Create a database:

mysql> CREATE database name;

7. Create a data sheet:

mysql> use database name;

Mysql> CREATE table name (field name varchar (20), field name char (1));

8. Delete the database:

mysql> drop database name;

9. Delete the data sheet:

mysql> drop table name;

10. Empty the records in the table:

mysql> Delete from table name;

11. Display the records in the table:

Mysql> select * from table name;

12. Insert a record into the table:

mysql> insert into table name values ("HyQ", "M");

13. Update the data in the table:

Mysql-> Update table name set field name 1= ' A ', field name 2= ' B ' where field name 3= ' C ';

14. Load the data into the data table in text mode:

mysql> Load Data local infile "d:/mysql.txt" into table name;

15. Import the. sql File command:

mysql> use database name;

Mysql> source D:/mysql.sql;

16. Change the root password on the command line:

mysql> Update Mysql.user Set Password=password (' New password ') where user= ' root ';

mysql> flush Privileges;

17. Display the database name for use:

Mysql> Select Database ();

18. Display the current User:

Mysql> Select User ();

Note: Each command is followed by; MySQL allows line-break input commands, which are separated from commands and commands. Note here, otherwise ...

MySQL Common command collection

Related Article

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.