1. Connect to the database
Win+r > cmd > Mysql-h localhost-uroot-p
2, the operation of the database
Creating database: Create database name;
Remove database: drop database name;
Show databases: Show databases;
Using database: Use database name;
3. Table operation
Show All tables: show tables;
Delete tables: drop table name;
Creating Table: Create table table name (ID int (one) unsigned NOT NULL Auto_increment primary key,
Display table structure: DESC table name;
Show CREATE TABLE statement: Show creates table table name;
Modify the name of the data table: ALTER TABLE name rename as new table name;
4. Table Data operation:
Insert Data: Insert into Table name (Field 1, Field 2 、、、) Values (value 1, value 2 、、、);
-
query data: select * from where condition limit 0.1];
To Modify the data: Update Table name Set Field name 1= value 1, field name 2= value 2 、、、 where conditions;
Delete data: Delete from Table name where conditions;
Authorized User rights: GRANT permissions on the database. Data table to User name @ login host identified by "password"
For example: Add a new user named Lisi, and the password is string "123".
Allow him to log on to any host and have access to queries, insertions, modifications, and deletions to all databases.
The first thing to do is log in as the root user
Then enter the following command:
GRANT select,insert,update,delete On * * to [e-mail protected] "%" identified by "123"
5, temporarily change the encoding format to GBK:set names GBK;
6. Common operation of MySQL database:
We can use the help command to query for shortcut keys:
Set up the data after the query: \g
Cancel the currently unfinished operation: \c
Exit Current client: \q exit
Show current server Status: \s
Display Help information for: \h (same as assist command)
Change performer: \d
DOS command: Clear screen CLS
This article is from the PHP Learning notes blog, so be sure to keep this source http://phpst.blog.51cto.com/6922579/1557927
Database Operations (DB)