Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySql adds statements such as user, authorization, password change, etc.

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report