设置允许计算机登录mysql服务器

mysql

M2d59ef9fe

允许任意计算机登录mysql服务器:GRANT ALL PRIVILEGES ON . TO ‘root‘@’%’ IDENTIFIED BY ‘root’ WITH GRANT OPTION;

1
2
3
4
5
6
mysql -uroot -p

GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘youpassword’ WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

FLUSH PRIVILEGES;

添加用户

以root用户登录数据库,运行以下命令:

1
create user yzht identified by 'Yzht8888-%$#';

查看用户

1
select User, Host, Password from mysql.user;

image-20210407095806727

授权

命令格式:grant privilegesCode on dbName.tableName to username@host identified by “password”;

1
2
grant all privileges on yzht.* to yzht@'%' identified by 'Yzht8888-%$#';
flush privileges;