MySQL 5.7 User and log management

Source: Internet
Author: User

Description:
Database is a very important part of information system, it is very important to manage it reasonably and efficiently. Typically, the total administrator creates different administrative accounts, and then assigns different operational permissions to those accounts to the appropriate managers.
Because log file is an important reference to master the state of database operation, the maintenance of log file is very important.
Next, do some things about the user and the log.

.
.

Lab environment: A virtual machine with database version 5.7 installed
.
.

1. Enter the database to view the user
To view users, you must first enter the MySQL database
Use MySQL; #先进入
Select User,authentication_string,host from user; #查看用户


.
.
2. Create user ' test01 ' @ ' localhost ' identified by ' 123123 '; #创建用户及密码
Grant all on . to ' test02 ' @ ' localhost ' identified by ' 123123 '; #创建用户及密码, if the user exists, the change, if not in the new


.
.
3. After setting up the user and password, you can change the user and password.
Rename user ' test01 ' @ ' localhost ' to ' user01 ' @ ' 192.168.200.128 '; #重命名用户及主机
Set password for ' user02 ' @ ' localhost ' = password (' qwe123 '); # change user password


.
.
4. Setting the password directly may be unsafe, then you can set the password with ciphertext
Select password (' 123123 '); #将密码转换成密文
Create user ' user02 ' @ ' localhost ' identified by password ' ciphertext '; #密文设置密码


.
.
5. Forget the password also has the solution method
Systemctl Stop Mysqld.service #关闭数据库
VIM/ETC/MY.CNF #进入配置文件
Last inserted in [mysqld]
Skip-grant-tables #跳过验证 (second photo)
Systemctl Start Mysqld.service #开启数据库
MySQL #进入数据库
Update mysql.user Set authentication_string = password
(' 123qwe ') where user= ' root '; #重新更改root用户密码
Quit
Then delete the INSERT statement in MY.COF
Restart database
You can then log in with the root user


Enter the configuration file configuration as

.
.
6. Granting and deleting of permissions
Show grants for ' Wang ' @ ' localhost '; #查看权限
Grant Select,update on . to ' Wang ' @ ' localhost ' identified by ' 123qwe '; #赋予修改与查询权限


revoke update on . from ' Wang ' @ ' localhost '; #删除权限

.
.
7. Here is the related log operation
Log files are added to the appropriate configuration file
Exit the database first and then enter the configuration file
Vim/etc/my.cnf
Last inserted in [mysqld]
Log-error=/usr/local/mysql/data/mysql_error.log #错误日志
General_log=no #开启通用日志
General_log_file=/usr/local/mysql/data/mysql_general.log #通用日志
Log_bin=mysql-bin #二进制日志
Slow_query_log=on #开启慢日志
Slow_query_log_file=mysql_slow_query.log #生成慢日志
long_query_time=1 #超出时间, 1s


then restart the database, enter the database, hibernate for three seconds, so the slow log will be logged.
can go to log storage directory to view
Cd/usr/local/mysql/data #日志目录


Command operation on the first here, the shortcomings of the hope to be able to put forward, I good convenience to improve

MySQL 5.7 User and log management

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.