MySQL Database learning experience (4)

Source: Internet
Author: User
Tags exit connect mysql mysql client import database mysql database

10. Data update of the table

(1) Change one field at a time, pay attention to grammar again. Text needs to be enclosed in quotes but not in numbers.

Mysql>update table01 Set field03= ' new info ' swheresfield01=1;

Query OK, 1 row Affected (0.00 sec)

(2) Change multiple fields at once, remembering to separate each updated field with a comma.

Mysql>update table01 set field04=19991022, field05=062218swheresfield01=1;

Query OK, 1 row Affected (0.00 sec)

(3) Update multiple data at once

Mysql>update TABLE01 Set field05=152901swheresfield04>19990101;

Query OK, 3 Rows Affected (0.00 sec)

11. Delete Data

Mysql>delete from Table01swheresfield01=3;

Query OK, 1 row Affected (0.00 sec)

12. Import Database Tables

(1) Create. sql file

(2) First create a library such as Auction.c:mysqlin>mysqladmin-u root-p creat auction, prompts for a password, and then successfully created.

(3) Import Auction.sql file

C:mysqlin>mysql-u Root-p Auction < Auction.sql.

By doing this, you can create a database auction and one of the table auction.

Authorization of the 13.mysql database

Mysql>grant Select,insert,delete,create,drop

On *.* (or test.*/user.*/.)

To User name @localhost

Identified by ' password ';

Such as: Create a new user account so that you can access the database, you need to do the following:

Mysql> Grant Usage

-> on test.*

-> to Testuser@localhost;

Query OK, 0 rows affected (0.15 sec)

Since then, a new user is created: testuser, this user can only connect to the database from localhost and connect to the test database. Next, we must specify what testuser this user can do:

mysql> GRANT Select, INSERT, Delete,update

-> on test.*

-> to Testuser@localhost;

Query OK, 0 rows Affected (0.00 sec)

This action enables TestUser to perform Select,insert and delete and update query operations in each table in the test database. Now we end the operation and exit the MySQL client program:

Mysql> exit

Bye

14. Authorize the MySQL user password

The default username for the MySQL database is "root" (similar to the SA for MS SQL Server) and the password defaults to null. At the DOS prompt (note, not the MySQL prompt), enter

c:mysqlin> "mysqladmin-u root-p password NewPassword

Return will prompt you to enter the original password, because the original password is empty, direct return, root user's password will be changed to "NewPassword".



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.