1. 创建新用户
登录以root登录MySQL之后,执行下面两条指令:
create user 'username'@'host' identified by 'password';
# host: % 表示任何ip都可以登录,localhost 表示仅可以本地登录,还可以指定ip,暂时没有尝试过指定域名
flush privileges;
# 刷新权限,也没有尝试过不刷新权限直接登录
Example:
xiaoyao@Ubuntu2004:~$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.20-0ubuntu0.20.04.1 (Ubuntu)
Copyright (c) 2000,