Linux terminal operation MySQL

Source: Internet
Author: User

1. Terminal startup MySQL:/etc/init.d/mysqlstart;

2. log in to MySQL:mysql-uroot-p ( log in with the root account) and enter the password;

3. View all database names:showdatabases;

4. Select a database operation:usedatabase_name;

5. View all the table names under the current database:showtables;

6. Creating a database:createdatabase database_name;

7. Delete a database:dropdatabase database_name;

8. Creating a table : Create TABLE mytest (UID bigint () NOT NULL, uname varchar (notnull);

9. Delete a table :d ROP table mytest;

10.SQL INSERT statement:insertinto table_name (COL1,COL2) values (value1,value2);

11.SQL UPDATE statement:updatetable_name set col1= ' value1 ', col2= ' value2 ' where where_definition;

12.SQL Query statement:select* from table_name where .... (The most complex statement )

13.SQL DELETE statement:deletefrom table_name where ...

Add a table structure field:alerttable table_name Add column field1 date, add column Field2 time ...

Delete a table structure field:alerttable table_name drop field1;

See the structure of the table: Showcolumns fromtable_name;

17.limit use: select* fromtable_name limit 3;// per page only 3 rows

select* from table_name limit 3,4// starting with the third of the query results, four results are displayed.

This is a good place to use for paging.

to sort the results of a query : SELECT * FROM table_name ORDER by Field1,orderby Field2; Multiple sorting

exit Mysql:exit;

Delete all the data in the table:truncate TABLE datasheet name (not recoverable)


Linux terminal operation MySQL

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.