MySQL command-line operation

Source: Internet
Author: User
Tags import database

Import Database:

1 Mysql>use ygeshop;

Ygeshop for Database name

2 Mysql>source the imported file name;

As I entered the command line: Mysql>source ygeshop.sql;

1. Display the list of databases.

show databases;

The default is two databases: MySQL and test. MySQL inventory in the MySQL system and user rights information, we change the password and the new user, is actually to operate the library.

2. Display the data table in the library:

Use MySQL;

Show tables;

3, display the structure of the data table:

describe table name;

4. Build the library and delete the library:

Create database name;

drop database name;

5, build the table:

Use library name;

CREATE TABLE table name (field list);

drop table name;

6. Clear the Table records:

Delete from table name;

7. Display the records in the table:

SELECT * from table name;

Recruit, export, and import data

1. Export Data:

Mysqldump--opt Test > Mysql.test

Export the database test database to the Mysql.test file, which is a text file

such as: Mysqldump-u root-p123456--databases dbname > Mysql.dbname

is to export the database dbname to the file mysql.dbname.

2. Import data:

Mysqlimport-u root-p123456 < Mysql.dbname.

You don't have to explain.

3. Import text data into the database:

The field data of the text data is separated by the TAB key.

Use test;

Load data local infile "file name" into table name;

1: Use the show statement to find out what database currently exists on the server:

Mysql> SHOW DATABASES;

2:2. Create a database Mysqldata

mysql> CREATE DATABASE Mysqldata;

3: Select the database you created

mysql> use Mysqldata; (press ENTER to appear database changed operation success!)

4: See what tables exist in the current database

Mysql> SHOW TABLES;

5: Create a database table

Mysql> CREATE TABLE MYTABLE (name VARCHAR), sex CHAR (1));

6: Show the structure of the table:

Mysql> DESCRIBE MYTABLE;

7: Add a record to the table

mysql> INSERT INTO MYTABLE values ("HyQ", "M");

8: Loading data into a database table in text mode (for example, D:/mysql.txt)

mysql> LOAD DATA LOCAL INFILE "D:/mysql.txt" into TABLE MYTABLE;

9: Import. sql File command (for example, D:/mysql.sql)

Mysql>use database;

Mysql>source D:/mysql.sql;

10: Delete Table

Mysql>drop TABLE MYTABLE;

11: Clear the table

Mysql>delete from MYTABLE;

12: Update data in table

Mysql>update MYTABLE set sex= "F" where name= ' HyQ ';

Posted on 2006-01-10 16:21 Happytian Read (6) Comments (0) Edit favorites to 365Key

13: Backing Up the database

Mysqldump-u Root Library name >xxx.data

14: Example 2: Connecting to MySQL on a 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-uroot-pabcd123

(Note: You and root can be used without spaces, others are the same)

3. Exit MySQL command: Exit (enter)

=====================================================================

1: Use the show statement to find out what database currently exists on the server:
Mysql> SHOW DATABASES;
2:2. Create a database Mysqldata
mysql> CREATE DATABASE Mysqldata;
3: Select the database you created
mysql> use Mysqldata; (press ENTER to appear database changed the operation is successful!) )
4: See what tables exist in the current database
Mysql> SHOW TABLES;
5: Create a database table
Mysql> CREATE TABLE MYTABLE (name VARCHAR), sex CHAR (1));
6: Show the structure of the table:
Mysql> DESCRIBE MYTABLE;
7: Add a record to the table
mysql> INSERT INTO MYTABLE values ("HyQ", "M");
8: Loading data into a database table in text mode (for example, D:/mysql.txt)
mysql> LOAD DATA LOCAL INFILE "D:/mysql.txt" into TABLE MYTABLE;
9: Import. sql File command (for example, D:/mysql.sql)
Mysql>use database;
Mysql>source D:/mysql.sql;
10: Delete Table
Mysql>drop TABLE MYTABLE;
11: Clear the table
Mysql>delete from MYTABLE;
12: Update data in table
Mysql>update MYTABLE set sex= "F" where name=hyq;

Https://jingyan.baidu.com/article/4e5b3e19505e9091901e24ba.html

Http://www.cnblogs.com/bluecobra/archive/2012/01/11/2318922.html

Http://www.jb51.net/article/74564.htm

MySQL command-line operation

Related Article

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.