参考:
https://blog.csdn.net/qq_15585305/article/details/129889474

# 先确保自己有授权权限mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;Query OK, 0 rows affected (0.00 sec)# 更新一下权限mysql> flush privileges;Query OK, 0 rows affected (0.01 sec)# 查询自己是否有权限mysql> SELECT host,user,Grant_priv,Super_priv FROM mysql.user;+---------------+------------------+------------+------------+| host| user | Grant_priv | Super_priv |+---------------+------------------+------------+------------+| localhost | root | Y| Y|+---------------+------------------+------------+------------+7 rows in set (0.00 sec)# 创建新用户mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changed# 这里的localhost换成%通配符,匹配所有hostmysql> CREATE USER 'root'@'%' IDENTIFIED BY '你的密码';Query OK, 0 rows affected (0.13 sec)# 授予新用户权限mysql> grant all on *.* to 'root'@'%';Query OK, 0 rows affected (0.01 sec)mysql> flush privileges;Query OK, 0 rows affected (0.01 sec)