MySQL command set

Source: Internet
Author: User

Mysql

Mysql-h host Address-u user name-P user Password

First open the DOS window, then enter the directory Mysql\bin, and then type the command Mysql-u root-p, enter after the prompt you to lose the password. Note that the user name can have a space or no space, but before the password must have no space, or let you re-enter the password.

If you have just installed MySQL, superuser root is no password, so the direct return to enter the MySQL, MySQL prompt is: mysql>

2. Connect to MySQL on the remote host. Assume the remote host IP is: 110.110.110.110, the user name is root, the password is abcd123. Type the following command:

Mysql-h110.110.110.110-u Root-p 123; (Note: You can not add a space between the root and the other)

Second, change the password

1, add a password to root ab12. First enter directory Mysql\bin under DOS, and then type the following command

2, then change the root password to djg345.

Third, create the database

1, CREATE database name;

2. GRANT select,insert,update,delete,create,drop,alter on database name. * To database name @localhost identified by ' password ';

' Database name ' @ ' localhost ' = old_password (' password ');

—————————————————————————————————————————————

Note: You must first log in to MySQL, the following actions are performed at the prompt of MySQL, and each command ends with a semicolon.

1, if you hit the command, enter after the discovery forgot to add a semicolon, you do not have to re-play the command, as long as a semicolon to enter the return on it.

2. You can use the cursor up and down keys to recall the previous command.

1. Displays the list of databases in the current database server:

Mysql> SHOW DATABASES;

mysql> CREATE database name;

mysql> use library name;

mysql> CREATE table name (field name VARCHAR (20), Field name CHAR (1));

mysql> DROP database name;

mysql> DROP table name;

Mysql> DELETE from table name;

mysql> INSERT into table name VALUES ("HyQ", "M");

mysql-> UPDATE table name SET field name 1= ' A ', field name 2= ' B ' WHERE field name 3= ' C ';

mysql> LOAD DATA LOCAL INFILE "d:/mysql.txt" into table name;

mysql> use database name;

Mysql> SOURCE D:/mysql.sql;

mysql> UPDATE mysql.user SET password=password (' New password ') WHERE user= ' root ';

mysql> FLUSH privileges;

Drop database if exists school; Delete if Sudu is present

Create DATABASE Sudu; Building a library Sudu

Use school; Open Library Sudu

(

Name Char (TEN) is not NULL,

Year Date

); End of Build table

Insert into teacher values (' ', ' Allen ', ' Fly number technology 1 ', ' 2005-10-10 ');

Insert into teacher values (' ', ' Jack ', ' Flight number Technology 2 ', ' 2005-12-23 '); If you type the above command at the MySQL prompt, it is not easy to debug.

Mysql-uroot-p Password < C:\sudu.sql

If successful, empty a row without any display, and if there is an error, there is a hint. (The above command has been debugged, you can use it only if you remove//comment).

(2) or enter the command line after using mysql> source C:\sudu.sql; You can also import the Sudu.sql file into the database.

1, the text data should conform to the format: The field data is separated by the TAB key, the null value is replaced by \ n. Example:

4 Mike Flying number technology 2 1975-12-23

2, the data incoming command, load data local infile "C:\sudu.txt" into the table name;

V. BACKUP DATABASE: (command executed in DOS \mysql\bin directory)

The export file is present in the Mysql\bin directory by default

Mysqldump-u user name-p database name > exported file name

Mysqldump-u user_name-p123456 database_name > Outfile_name.sql

Mysqldump-u user name-P database name Table name > exported file name

MYSQLDUMP-U USER_NAME-P database_name table_name > OUTFILE_NAME.SQL

Mysqldump-u User_name-p-D--add-drop-table database_name > Outfile_name.sql

4. Export with language parameters

Mysqldump-uroot-p--default-character-set=latin1--SET-CHARSET=GBK--skip-opt database_name > Outfile_name.sql

MySQL command set

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.