MySql adds statements such as user, authorization, password change, etc.
MySql adds statements such as user, authorization, password change, etc.
Database top_develop
Log into the database
1: new users
[mysql@lcamdb] $mysql-u root-p
Enter password: *
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
Mysql > use mysql
Mysql > insert into mysql.user (Host,User,Password,ssl_cipher,x509_issuer,x509_subject) values ("localhost", "top_hdz", password ("top_hdz"),')
Query OK, 1 row affected (0.00 sec)
Mysql > FLUSH PRIVILEGES
Query OK, 0 rows affected (0.00 sec)
Mysql > SELECT host, user, password FROM user WHERE user = "top_hdz"
+-- +
| | host | user | password | |
+-- +
| | localhost | top_hdz | * 9E2182EFC0FDC01E6EDC9FE113C4158587B31889 |
+-- +
1 row in set (0.00 sec)
Perform a login test
[mysql@lcamdb mysql] $mysql-u top_hdz-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 35
Server version: 5.6.17 Source distribution
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
Mysql > use top_develop
ERROR 1044 (42000): Access denied for user 'top_hdz'@'localhost' to database' top_develop'
2: authorization to access all objects in the top_develop database
Grant all privileges on top_develop.* to top_hdz@localhost identified by 'top_hdz'
Query OK, 0 rows affected (0.00 sec)
Mysql > flush privileges
Query OK, 0 rows affected (0.00 sec)
After the permissions are added:
Mysql > use top_develop
ERROR 1044 (42000): Access denied for user 'top_hdz'@'localhost' to database' top_develop'
Mysql > use top_develop
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-A
Database changed
Mysql > exit
Bye
If you want to assign partial permissions to a user, you can write like this:
Mysql > grant select,update on top_develop.*
3. Delete the user.
@ > mysql-u root-p
@ > password
Mysql > Delete FROM user Where User= "top_hdz" and Host= "localhost"
Mysql > flush privileges
/ / Delete the user's database
Mysql > drop database top_develop
4. Modifies the specified user password.
@ > mysql-u root-p
@ > password
Mysql > update mysql.user set password=password ('new password') where User= "top_hdz" and Host= "localhost"
Mysql > flush privileges
5. List all databases
Mysql > show database
6. Switch database
Mysql > use 'database name'
7. List all tables
Mysql > show tables
8. Show data table structure
Mysql > describe table name
9. Delete databases and data tables
Mysql > drop database database name
Mysql > drop table datasheet name