Summary of common operations for beginners on MySQL Study Notes

Source: Internet
Author: User

Last time we introduced: Suitable for beginnersMySQLTake note of the MySQL query example. Here we will introduce MySQLCommon Operations of Database AdministratorsNext, let's take a look at this part.

Common Operations:

1: Use the SHOW statement to find out the current database on the server:

Mysql> show databases;

2: Create a database MYSQLDATA

Mysql> Create database mysqldata;

3: select the database you created

Mysql> use mysqldata; (when you press the Enter key to see Database changed, the operation is successful !)

4: view the tables in the current database

Mysql> show tables;

5. Create a database table

Mysql> Create table mytable (name VARCHAR (20), sex CHAR (1 ));

6: display the table structure:

Mysql> describe mytable;

7. Add records to the table

Mysql> insert into MYTABLE values ("hyq", "M ");

8: load data into a database table in text format, for example, D:/mysql.txt)

Mysql> load data local infile "D:/mysql.txt" into table mytable;

9: import. SQL file commands such as D:/mysql. SQL)

Mysql> use database;

Mysql> source d:/mysql. SQL;

10: delete a table

Mysql> drop table mytable;

11: Clear the table

Mysql> delete from MYTABLE;

12: Update table data

Mysql> update MYTABLE set sex = "f" where name = 'hyq ';

Connect to MYSQL

Format: mysql-h host address-u user name-p User Password

Example 1: connect to MYSQL on the local machine

First, open the DOS window, enter the directory mysqlbin, then type the command mysql-uroot-p, and press enter to prompt you to enter the password. If you have just installed MYSQL, super User root has no password, so press enter to enter MYSQL. The MYSQL prompt is: mysql>

Example 2: connect to MYSQL on the remote host

Assume that the IP address of the remote host is 110.110.110.110, the user name is root, and the password is abcd123. Enter the following command:

Mysql-h110.110.110.110-uroot-pabcd123

Note: u and root do not need to add spaces. The same applies to others)

Exit MYSQL command: exit and press Enter)

Change Password

Format: mysqladmin-u username-p old password New password

Example 1: Add a password ab12 to the root user. First, enter the directory mysqlbin in DOS, and then type the following command:

Mysqladmin-uroot-password ab12

Note: because the root account does not have a password at the beginning, the old-p password can be omitted.

Example 2: Change the root password to djg345.

Mysqladmin-uroot-pab12 password djg345

Here is a summary of the common operations of MySQL database administrators suitable for beginners. I hope this introduction will be helpful to you!

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.