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