Basic mysql operations

Source: Internet
Author: User
Tags mysql commands
I plan to write some knowledge about database operations. Now I have finished the first article. The following is a record of basic knowledge about mysql operations.

I plan to write some knowledge about database operations. Now I have finished the first article. The following is a record of basic knowledge about mysql operations.

Start and Stop the mysql service in the window

Start mysql database
Net start mysql

Stop a mysql database
Net stop mysql

Restart the mysql database
Net restart mysql


Command line format: use of basic mysql commands

1. Command Cancellation
\ C

2. Exit the mysql window.
Exit; or quit; or ctrl + c

3. view the database version number
Select version ();

4. display the existing database
Show databases;

5. Select test Database
Use test;

6. view the selected Database
Select database ();

7. Set the Chinese encoding of the database
Set names utf8;

8. Create a test Database
Create database test

9. Create an mtest table
Create table mtest (
Id tinyint (2) unsigned not null auto_increment,
Name varchar (20 ),
Sex char (1 ),
Email varchar (50 ),
Birth datetime,
Primary key (id)
);

10. Insert a data entry into the mtest table
Insert into mtest ('name', 'sex', 'email ', 'birth') values ('hangsan', '1', 'hangsan @ 163.com ', now ());

11. Query Information in the mtest table whose name is John
Select * from mtest where name = 'hangsan ';

12. Output in descending order by ID
Select * from mtest order by id desc;

13. Display 11th to 20 data records
Select * from mtest id limit 10, 10;

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.