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

Ways to add users, create new databases, authorize users, delete users and change passwords in MySql

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

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "adding users, creating a new database, user authorization, deleting users and changing passwords in MySql". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Create a new user.

/ / Log in to MYSQL

@ > mysql-u root-p

@ > password

/ / create a user

Mysql > mysql > insert into mysql.user (Host,User,Password,ssl_cipher,x509_issuer,x509_sub

Ject) values ("localhost", "pppadmin", password ("passwd"),'')

This creates a user named: lamp password: 1234.

And log in.

Mysql > exit

@ > mysql-u phplamp-p

@ > enter your password

Mysql > Login succeeded

two。 Authorize the user.

/ / Log in to MYSQL (with ROOT permission). I log in as ROOT.

@ > mysql-u root-p

@ > password

/ / first create one for the user (phplampDB)

> create database phplampDB

/ / authorized phplamp users have all permissions in the phplamp database.

> grant all privileges on phplampDB.* to phplamp@localhost identified by '1234'

/ / refresh the system permissions table

Mysql > flush privileges

Mysql > other actions

/ *

If you want to assign partial permissions to a user, you can write like this:

Mysql > grant select,update on phplampDB.* to phplamp@localhost identified by '1234'

/ / refresh the system permission table.

Mysql > flush privileges

, /

3. Delete the user. Www.2cto.com

@ > mysql-u root-p

@ > password

Mysql > Delete FROM user Where User= "phplamp" and Host= "localhost"

Mysql > flush privileges

/ / Delete the user's database

Mysql > drop database phplampDB

4. Modifies the specified user password.

@ > mysql-u root-p

@ > password

Mysql > update mysql.user set password=password ('new password') where User= "phplamp" 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

That's all for adding users, creating new databases, authorizing users, deleting users and changing passwords in MySql. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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