MySQL Common commands

Source: Internet
Author: User
Tags mysql backup mysql import

  1. Create Database test_db; Create a database named test_db

  2. Use test_db; Enter the TEST_DB database

  3. Show tables; See how many tables are in the database

  4. Drop database test_db; Deleting a database

  5. drop table test01; Delete a table

  6. Delete from test01; Clear Table Contents

  7. Show variables like '%char% '; View the database character set

  8. INSERT into test01 values ("001", "JF1"); Inserts data into the table.

  9. SELECT * from test01; View test01 table data content.

  10. CREATE TABLE test01 (ID varchar (), name varchar (20));

  11. Grant all privileges the test_db.* to [e-mail protected] identified by ' 123456 ';

  12. Grant all on test_db.* to [e-mail protected] identified by ' 123456 ';

  13. Grant Select,insert,update,delete on * * to [e-mail protected] "%" identified by ' 123456 '; authorize MySQL database.

  14. Flush privileges; Refresh Permissions

  15. mysqldump–uroot–p123456 test_db >/tmp/test.db.sql; MySQL Backup or export

  16. mysql–uroot–p123456 test_db </tmp/test.db.sql; MySQL Import

  17. mysqladmin–uroot–p123456 password NewPassword; Modify the MySQL root password

  18. Drop database test_db; Deleting a database

  19. drop table test01; Delete a table

  20. Delete from test01; Clear Table Contents

  21. Show variables like '%char% '; View the database character set

  22. INSERT into test01 values ("001", "WUGK1"); Inserts data into the table.

  23. SELECT * from test01; View test01 table data content.

  24. CREATE TABLE test01 (ID varchar (), name varchar (20));

  25. ALTER TABLE Ip_can drop ID; Delete a field
    ALTER TABLE Ip_can Add ID varchar (20); Add a field
    ALTER TABLE Ip_can Add ID varchar (a) first;

In subsequent continuous updates

This article is from the "Fluffy Duck" blog, please be sure to keep this source http://woshitieren.blog.51cto.com/2466034/1681211

MySQL Common commands

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.