In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to manage users and logs in MySQL 5.7. the content of the article is carefully selected and edited by the author, and it has a certain pertinence, and it is of great significance to everyone's reference. The following is to understand with the author how to manage users and logs in MySQL 5.7.
Description:
Database is a very important link in the information system, and it is very important to manage it reasonably and efficiently. Usually, the chief administrator creates different administrative accounts, then assigns different operation permissions, and gives these accounts to the appropriate managers to use.
Because the log file is an important reference to grasp the running status of the database, so the maintenance of the log file is also of great significance.
Next, do something about users and logs.
.
.
Experimental environment: a virtual machine with database version 5.7
.
.
1. Go to the database and view the user
To view users, you must first go to the mysql database
Use mysql; # enter first
Select user,authentication_string,host from user; # View users
.
.
2. Create user 'test01'@'localhost' identified by' 123123 users; # create users and passwords
Grant all on. To 'test02'@'localhost' identified by' 123123 password; # create a user and password. If the user exists, change it. If not, create a new one.
.
.
3. After setting the user and password, you can also change the user and password
Rename user 'test01'@'localhost' to' user01'@'192.168.200.128';# renames users and hosts
Set password for 'user02'@'localhost' = password (' qwe123'); # change the user's password
.
.
4. It may be insecure to set the password directly, so you can set the password in ciphertext.
Select password ('123123'); # convert passwords to ciphertext
Create user 'user02'@'localhost' identified by password' ciphertext; # ciphertext set password
.
.
5. There is also a way to forget your password.
Systemctl stop mysqld.service # shut down the database
Vim / etc/my.cnf # enter the configuration file
Insert at the end of [mysqld]
Skip-grant-tables # Skip validation (figure 2)
Systemctl start mysqld.service # Open the database
Mysql # enter the database
Update mysql.user set authentication_string = password
('123qwe') where user='root'; # re-change the root user password
Quit
Then delete the insert statement in my.cof
Restart the database
At this point, you can log in with the root user.
Enter the configuration file as shown below
.
.
6. Authorization and deletion of authority
Show grants for 'wang'@'localhost'; # View permissions
Grant select,update on. To 'wang'@'localhost' identified by' 123qweeting; # Grant permission to modify and query
Revoke update on. From 'wang'@'localhost'; # remove permission
.
.
7. Here are the related log operations
Log files are added to the appropriate configuration file
Exit the database first, and then enter the configuration file
Vim / etc/my.cnf
Insert at the end of [mysqld]
Log-error=/usr/local/mysql/data/mysql_error.log # error log
General_log=NO # enable General Log
General_log_file=/usr/local/mysql/data/mysql_general.log # General Log
Log_bin=mysql-bin # binary log
Slow_query_log=ON # enable slow log
Slow_query_log_file=mysql_slow_query.log # generates slow logs
Long_query_time=1 # out of time, 1s
Then restart the database, enter the database, hibernate for three seconds, so that the slow log will be recorded.
You can check it in the log storage directory
Cd / usr/local/mysql/data # log directory
After reading the above about MySQL 5.7how to manage users and logs, many readers must have some understanding. If you need more industry knowledge and information, you can continue to follow our industry information section.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.