centos mysql8 设置远程访问

2023-12-26 13:04:27

参考:
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 names
You can turn off this feature to get a quicker startup with -A
Database changed
# 这里的localhost换成%通配符,匹配所有host
mysql> 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)

文章来源:https://blog.csdn.net/sinat_26809255/article/details/135217927
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。