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

How to create users and change passwords in mysql

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

Share

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

This article mainly explains "how mysql creates users and modifies passwords." Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "mysql how to create users and modify passwords"!

MySql add users, new database, user authorization, delete users, modify passwords (note that each line is followed by; indicates the end of a command statement):

1. new user

1.1 Login to MYSQL:

@>mysql -u root -p

@> Password

1.2 Create User:

mysql> insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));

This creates a user named test with password 1234.

Note: "localhost" here means that the user can only log in locally and cannot log in remotely from another machine. If you want to log in remotely, change "localhost" to "%" to indicate that you can log in from any computer. You can also specify that a machine can log in remotely.

1.3 Then log in:

mysql>exit;

@>mysql -u test -p

@> Enter password

mysql> Login successful

2. Authorize users

Authorization format: grant permission on database.* to username @ login host identified by "password";

2.1 Log in MYSQL (with ROOT privileges), log in as ROOT here:

@>mysql -u root -p

@> Password

2.2 First create a database (testDB) for the user:

mysql>create database testDB;

2.3 Authorize test user to have all permissions on testDB database (all permissions on a database):

mysql>grant all privileges on testDB.* to test@localhost identified by '1234';

mysql>flush privileges;//Refresh the system privileges table

Format: grant permissions on database.* to username @ login host identified by "password";

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

mysql>grant select,update on testDB.* to test@localhost identified by '1234';

mysql>flush privileges; //Refresh the system privileges table

2.5 Authorize the test user to have certain permissions on all databases:

mysql>grant select,delete,update,create,drop on *.* to test@"%" identified by "1234";

//test The user has select,delete,update,create,drop permissions on all databases.

//@"%" indicates authorization for all non-local hosts, excluding localhost. (localhost address is set to 127.0.0.1. If it is set to a real local address, I don't know if it can be verified.)

//grant all privileges on testDB. to test@localhost identified by '1234';.

3. delete user

@>mysql -u root -p

@> Password

mysql>Delete FROM user Where User='test' and Host='localhost';

mysql>flush privileges;

mysql>drop database testDB; //Delete user database

Delete account and permissions: >drop user username @'%';

>drop user username @ localhost;

4. Modify the specified user password

@>mysql -u root -p

@> Password

mysql>update mysql.user set password=password ('new cipher') where User="test" and Host="localhost";

mysql>flush privileges;

5. List all databases

mysql>show database;

6. cutover database

mysql>use 'database name';

7. List all tables

mysql>show tables;

8. Display data table structure

mysql>describe table name;

9. Delete databases and data tables

mysql>drop database name;

mysql>drop table name;

mysql modify user password and mysql forget password solution

Change password:

The copy code is as follows:

//Select database

use mysql;

//Change password

update user set password=password ('new password') where user='root';

//Effective immediately

flush privileges

Forgot administrator password:

Under the [mysqld] field of my.ini, add:

The copy code is as follows:

skip-grant-tables

Restart mysql service, mysql at this time does not need a password to log in to the database

Then enter MySQL.

The copy code is as follows:

use mysql;update user set password=password ('new password') where user='root';

flush privileges

After running, remove skip-grant-tables from my.ini and restart mysql.

At this point, I believe everyone has a deeper understanding of "how mysql creates users and modifies passwords," so you might as well actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

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

Servers

Wechat

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

12
Report