MySQL 安装维护
配置时区
serverTimezone=Asia/Shanghai
开启 BinLog
- 1.修改mysql的my.ini文件,增加以下内容
log-bin=mysql-bin
binlog-format=ROW
-
2.重启mysql
-
3.查看bin_log是否成功开启:
show variables like 'log_bin';
修改密码
-
vim /etc/my.cnf # or vim /etc/mysql/my.cnf -
Add
skip-grant-tablesunder[mysqld] -
Restart MySQL
-
You should be able to log in to MySQL now using the below command
mysql -u root -p -
Run
mysql> flush privileges; -
Set new password by
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';如果提示密码等级低:输入:
SET GLOBAL validate_password.policy=LOW; -
Go back to
/etc/my.cnfand remove/commentskip-grant-tables -
Restart MySQL
-
Now you will be able to login with the new password
mysql -u root -p
设置必要权限:
grant SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER on 数据库名称.* to 'qrt_user'@'%';
撤销所有权限
revoke all on *.* from 'qrt_user'@'%';
展示授予了那些权限:
show grants for 'qrt_dev'@'%'; // % 表示所有主机
注意: 全局权限,不可以指定在某一个库上, 如: process 就是一个全局权限
Authentication Plugins
-- 新增用户的时候 可以指定使用那个授权插件
-- WITH 后指定了使用那个授权插件, 如果不知道就使用默认的, mysql8.0 默认使用caching_sha2_password, 需要客户端支持;
CREATE USER 'sha2user'@'localhost'
IDENTIFIED WITH caching_sha2_password BY 'password';
-- 使用默认授权插件
CREATE USER 'sha2user'@'localhost'
IDENTIFIED BY 'password';
账户相关操作: https://dev.mysql.com/doc/refman/8.0/en/creating-accounts.html
扩展:
- \G 表示将结果按列打印

浙公网安备 33010602011771号