简介
刚安装的数据库,用户远程访问失败,因此需配置允许用户远程登陆。
详细步骤
在 MySQL 服务器使用 root 账户登录
root@2cef0b670068:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 8.0.40 MySQL Community Server - GPL
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
切换到 mysql 数据库
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
mysql>
查看用户是否存在
mysql> SELECT User, Host FROM user WHERE User='gitea';
+-------+------+
| User | Host |
+-------+------+
| gitea | % |
+-------+------+
1 row in set (0.00 sec)
备注: 这里的 Host 已经是 %, 则表示可以从任意地址登录。
可选: 如果不存在可以创建用户
mysql> CREATE USER 'gitea'@'%' IDENTIFIED BY 'gitea';
配置允许任何地址登录
mysql> GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'%';
刷新权限
mysql> FLUSH PRIVILEGES;
退出数据库
mysql> EXIT;
以上便是本文的全部内容,感谢您的阅读。