MySQL Basic statement

Source: Internet
Author: User

mysqladmin-u root password ' 123 ' [[email protected] ~]# mysqladmin-u root password ' 123456 ' #明文设置密码 [[email protected ] ~]# mysql-u root–p #密文设置密码设置密码mysql-u root-p-h localhost local login database-hshow databases; View database show tables; view data sheet; us e library name; Toggle database describe table name; View table structure;

Increase:

Create database name; creation table table name (field 1 value, field 2 value ...). ); Create a data table insert into table name (Field 1, Field 2 ...). Values (data 1, data 2 ...) Insert data Create user username @ Login address identified by ' password '

By deleting:

drop database name; drop table name; Delete datasheet delete from table name; Delete all data from table deletes from table name where field deletes a record in table

Change:

Update table name set field 1 where Field 2 modifies data for Field 1 Update table name set field 1 where Field 2 between NUM1 and num2 modify the value of the field from NUM1 to num2 grant permissions on the database. Data Table to ' user ' @ ' address '; Modify permissions revoke permissions 1, permissions 2 on database. Data table from ' User ' @ ' address '; remove permissions set Password=password ("password") modify administrator password or normal user to modify their own password set Password for ' user ' @ ' address ' =password ("password") to modify the normal user password

Check:

Select field from table name; View data in table

Backup:

Mysqldump-u root-p Database > 1.sql

Back up the database to 1.sql

Mysql-u Root-p < 1.sql

Restore 1.sql

Mysqldump-u root-p Database Data Sheet > 2.sql

Back up a table in the database to 2.sql

Mysql-u Root-p Database < 2.sql

Restore data tables

Mysqldump-u root-p--databases Database 1 database 2 > 3.sql

Backing up multiple databases

Mysql-u Root-p < 3.sql

Restore all databases

Mysql-u root-p--all-databases > 4.sql

Back up all databases

This article is from the "stand in the Cloud" blog, be sure to keep this source http://9827789.blog.51cto.com/9817789/1664454

MySQL Basic statement

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.