Some operations on the MySQL database

Source: Internet
Author: User

  Startup : net start MySQL

  Close : net stop MySQL (can also be used with quit;)

  Log on to Mysql:mysql-u root-p

-u : The name of the user to log in;

-P : tells the server that a password will be used to log in, ignoring this option if the user name password you want to log in is blank

  Select the database you want to manipulate :

Name of the use database; (success will show databases changed

  To create a new data table:

1 Create TableStudents2 (3IdintUnsigned not NULLAuto_incrementPrimary Key,4NameChar(8) not NULL,5SexChar(4) not NULL,6AgetinyintUnsigned not NULL,7TelChar( -)NULL default"-"8);

If the field is set to Auto-increment, you must set the primary key primary key,auto-increment is the number that is automatically incremented for the primary key.

If the code is too long, you may enter an error, you can use the Redirect method to enter the statement through any text editor and save it as a Xx.sql file, and execute the script through the file redirection at the command prompt. Open a command prompt and enter:

1 - - - < file name

  

  To query the data in a table :

Select  from [ query conditions ] ; Select  from where condition; (can be added to the above conditions)

  to insert data into a table:

Insert [into] [(column name 1, column name 2, column name 3, ...) ] VALUES (value 1, value 2, value 3, ...);

  Change Database Password :

- -p password New password

  after changing the password to use : Flush privileges;

  List all databases : show databases;

  list all tables in the database : show tables;

  

  

Some operations on the MySQL database

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.