Simple Mysql operation and mysql operation

Source: Internet
Author: User

Simple Mysql operation and mysql operation

 

// Mysql version: 5.7.13

 

1. Run the command prompt as an administrator and go to the mysql installation location.
2. start the mysql service: net start mysql
3. Log On As A root user: mysql-uroot-p enter key


4. list all databases: show databases;
5. create a database: create databasesDatabase_Name;
6. Check whether the database is created again: create databases if not existsDatabase_Name;
7. delete a database: drop databaseDatabase_Name;
8. Select a database: useDatabase_Name;


9. list all data tables in the selected Database: show tables;
10. show columns fromTable_Name; Or: describeTable_Name;
11. select the display data table: select * fromTable_Name;
12. data table with conditions: select * fromTable_Name WhereId> = 2;
13. create a data table: create tableTable_Name(Col_01_NameType Details,Col_02_NameType Details ,...);
14. First judge and then create a data table: create table if not existsTable_Name(...);
15. Copy a data table: create tableTable_Name_01Select * fromTable_Name_02;
16. Rename the data table: alter tableTable_NameRenameNew_Table_Name; Or: rename tableOld_NameToNew_Name;
17. delete a data table: drop tableTable_Name;


18. Add a record to the data table: insertTable_NameSetCol_01=Value1,Col_02=Value2;
19. Modify the record in the data table: updateTable_NameSetCol_Name=New_ValueWhereId= 1;
20. delete the record in the data table: delete fromTable_Name;
21. Deletion of records in a data table with conditions: delete fromTable_NameWhereId= 1;


22. # view the current time: select now ();
23. # current user: select user ();
24. # current database program version: select version ();
25. # Current status: show status;
26. # view the connected user: show processlist;

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.