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