MySQL创建用户与授权

linux 191 2022-06-17 07:47

MySQL创建用户与授权

一. 创建用户

命令:

CREATE USER 'username'@'host' IDENTIFIED BY 'password';

CREATE USER 'root1'@'host' IDENTIFIED BY 'DaikuanTest888..';

GRANT REPLICATION SLAVE ON *.* TO 'root1'@'%' IDENTIFIED BY'DaikuanTest888..';

show master status;

+------------------+----------+--------------+------------------+

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |

+------------------+----------+--------------+------------------+

| mysql-bin.000001 | 107 | | |

+------------------+----------+--------------+----with--------------+

2.权限设置及说明

2.1添加远程ip访问权限

GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY 'SglDB666Admin' WITH GRANT OPTION; flush privileges;

select host,user,plugin,authentication_string from mysql.user;