MySQL review notes II_MySQL

Source: Internet
Author: User
MySQL review notes II bitsCN.com

MySQL review notes II

1. set a password for the root administrator account

Generally, the default MySQL root password is blank. if you have not set the root password before, use the mysqladmin command,

You can use the following mysqladmin command to modify the root password:

$ Mysqladmin-uroot-p password 123456

(Equivalent to $ mysqladmin-u root-p password 123456)

Enter password: (Enter the old password. Because the default password is blank, press enter here)

2. log on to the mysql database as a root administrator account

$ Mysql-uroot-p

(Equivalent to $ mysql-u root-p)

Enter password: (Enter the password set for the root account in the previous step)

3. how can I identify the current logon account as root?

Enter the use mysql command. if the command is executed successfully, the current logon account is the root account.

4. how to view the root password in the mysql system table (do not expect it to be in plain text )?

# Using System Tables

Use mysql;

# Query the password of the root account (the returned result is encrypted)

Select password from user where user = 'root ';

5. after logging on to the mysql database as a root account, how can I change the password of the root account by updating the system table?

# Using System Tables

Use mysql;

# Change the password of the root account by updating the system table

Update user set password = PASSWORD ('000000') where user = 'root ';

# Make the change take effect (if the following command is not executed, the new password will not take effect)

Flush privileges;

6. modify the password of the root account with one line of command

# Change old password 12345 to new password 54321

$ Mysqladmin-u root-p 12345 password 54321

(Equivalent to $ mysqladmin-uroot-p12345 password 54321)

VII. SQL statements related to database operations

# View all databases

Show databases;

# Create a database named db (requires certain permissions, which can be root, but not anonymous users)

Create database db;

# Use a database named db

Use db;

# Deleting a database named db

Drop database db;

# Exit mysql database

Quit or exit.

8. log on to the mysql database as an anonymous user

$ Mysql

9. log on to the mysql database on the remote host

$ Mysql-h110.110.110.110-uroot-p123456;

BitsCN.com

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.