Mysql Database user Password management

Source: Internet
Author: User

Database is a very important part of information system, it is very important to manage it reasonably and efficiently. Typically, the total administrator creates a different administrative account, and then assigns different permissions to the operation, calling the accounts to the appropriate managers. MySQL user information is stored in the MySQL library in the Users table. First, user management

1. Create a new User:

CREATE USER ‘用户名‘@‘主机‘ IDENTIFIED BY PASSWORD ‘密码‘;

2. Delete a user

DROP USER ‘用户名‘@‘主机‘;

3. Renaming:

RENAME USER ‘用户名‘@‘主机‘ TO ‘修改后的用户名‘@‘修改后的主机‘;
Two. Set the password for the user:

1. Modify the current login user password:

SET PASSWORD=PASSWORD(‘密码‘);

2. Modify other user passwords:

SET PASSWORD FOR ‘用户名‘@‘主机‘=PASSWORD(‘密码‘);

3. The solution to the forgotten root password:

1) Close the database

2) Check the port and whether it is off.

netstat -antp | grep 3306

3) Log in using the Bypass User table validation. Enter the MySQL configuration file, and under Mysqld, add the following to restart the service.

vim /etc/my.cnf[mysqld]user = mysqlbasedir = /usr/local/mysqldatadir = /usr/local/mysql/dataport = 3306character_set_server=utf8pid-file = /usr/local/mysql/mysqld.pidsocket = /usr/local/mysql/mysql.sockserver-id = 1skip-grant-tables    #加入此行命令

4) Restart Service

5. Enter MySQL directly into MySQL database, no password is required at this time.

mysql

6. Then use the following statement to change the password:

update mysql.user set authentication_string=password(‘qwe123‘)where user=‘root‘;

7. Exit the MySQL database and enter the statement that was added before the configuration file was deleted Skip-grant-tables

exit删除使用跳过user表验证的方式登录的语句

8. Restart the database service, enter the database, at this time the login is to use the password you changed.

systemctl restart mysqld.service mysql -uroot -p修改过的密码

Mysql Database user Password management

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.