centos7环境通过rpm包安装mysql8.0.19简单添加用户并授权
centos7环境通过rpm包安装mysql8.0.19
mysql的rpm包下载地址:
http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-8.0/
# 下载mysql8.0.19版本
mysql-community-client-8.0.19-1.el7.x86_64.rpm
mysql-community-common-8.0.19-1.el7.x86_64.rpm
mysql-community-libs-8.0.19-1.el7.x86_64.rpm
mysql-community-server-8.0.19-1.el7.x86_64.rpm
注意安装顺序 common -> libs -> client -> server
rpm -ivh mysql-community-common-8.0.19-1.el8.x86_64.rpm
[root@node1 data]# rpm -ivh mysql-community-server-8.0.19-1.el7.x86_64.rpm
warning: mysql-community-server-8.0.19-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libaio.so.1()(64bit) is needed by mysql-community-server-8.0.19-1.el7.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-8.0.19-1.el7.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-8.0.19-1.el7.x86_64
net-tools is needed by mysql-community-server-8.0.19-1.el7.x86_64
# 解决办法:
yum install net-tools.x86_64 libaio -y
# 初始密码在日志中
[root@node1 data]# more /var/log/mysqld.log
2020-03-12T16:11:00.530337Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.19) initializing of server in progress as process 32091
2020-03-12T16:11:08.553289Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Vct!CiL9qlo&
2020-03-12T16:11:12.228434Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 32140
2020-03-12T16:11:13.459708Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-03-12T16:11:13.515224Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.19' socket: '/var/lib/mysql/mysql.sock' port: 3306 My
SQL Community Server - GPL.
2020-03-12T16:11:13.571225Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
# 修改root密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Jad(2020';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
# 授予增删改查权限用户
CREATE USER 'ove_user'@'172.30.0.%' IDENTIFIED BY 'pass';
grant select,insert,update,delete ON ove.* TO 'ove_user'@'172.30.0.%';
# 只有查询权限用户
CREATE USER 'vid_read'@'172.30.0.%' IDENTIFIED BY 'pass';
grant select on ove.* TO 'vid_read'@'172.30.0.%';
# 授权
grant select,insert,update,delete privileges on vidcloud_res_oa.* TO 'ove_user'@'%' WITH GRANT OPTION;
grant all privileges on vidcloud_res_oa.* TO 'ove_user'@'%' WITH GRANT OPTION;
# 添加root账号
CREATE USER 'root'@'127.0.0.1' IDENTIFIED BY 'pass';
grant all privileges on *.* TO 'root'@'127.0.0.1' WITH GRANT OPTION;
3.回收权限
语法 : revoke 权限 on 数据库.数据库表 from '用户名'@'ip';
案例:revoke all privileges on ove.* from 'graphics_user_write'@'172.30.0.%';
flush privileges;