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 create new users and databases and authorize

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

I. create a new user

/ / Log in to MYSQL

Root@log:~# mysql-uroot-p

Enter password: password

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 138

Server version: 5.5.53-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2016, 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.

/ / create a user

Mysql > insert into mysql.user (Host,User,Password) values ("localhost", "zhouyuyao", password ("Zhouyuyao123"))

Mysql > insert into mysql.user (Host,User,Password) values ("%", "zhouyuyao", password ("Zhouyuyao123"))

/ / refresh the system permissions table

Mysql > flush privileges

This creates a user named: zhouyuyao password: Zhouyuyao123.

Second, login test

Mysql > exit

@ > mysql-u zhouyuyao-p

@ > enter your password

Mysql > Login succeeded

III. User authorization

/ / Log in to MYSQL

@ > mysql-u root-p

@ > password

/ / first create a database (test) for the user

Mysql > create database test

/ / authorized zhouyuyao users have all permissions of the test database

Mysql > grant all privileges on test.* to zhouyuyao@'%' identified by 'Zhouyuyao123'

/ / refresh the system permissions table

Mysql > flush privileges

Mysql > other actions

IV. Partial authorization

Mysql > grant select,update on test.* to zhouyuyao@localhost

Identified by 'cplusplus.me'

/ / refresh the system permissions table

Mysql > flush privileges

Delete users

@ > mysql-u root-p

@ > password

Mysql > DELETE FROM user WHERE User= "zhouyuyao" and Host= "localhost"

Mysql > flush privileges

Delete the database

Mysql > drop database test

7. Change the password

@ > mysql-u root-p

@ > password

Mysql > update mysql.user set password=password ('new password') where

User= "zhouyuyao" and Host= "localhost"

Mysql > flush privileges

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