Mysql 8 远程访问
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50570592/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mysql 8 remote access
提问by sHaDeoNeR
I usualy setup correctly MySQL for having remote access.
我通常正确设置 MySQL 以进行远程访问。
And currently I got stuck with MySQL 8.
目前我被 MySQL 8 困住了。
The first thing is that on the mysql.conf.d/mysqld.cnf , I don't have any bind-address line, so I added it by hand (bind-address 0.0.0.0) And I granted access to the user on '%'
第一件事是在 mysql.conf.d/mysqld.cnf 上,我没有任何绑定地址行,所以我手动添加了它(绑定地址 0.0.0.0)并且我授予用户访问权限'%'
When I connected I got the message "Authentication failed"
当我连接时,我收到消息“身份验证失败”
But it works well on localhost/command line
但它在本地主机/命令行上运行良好
回答by rbz
- Delete or comment the
bind_address
parameter from themy.ini
file.
bind_address
从my.ini
文件中删除或注释参数。
(The file name is different depend on the OS. On Linux my.ini is actually my.cnf located in directory /etc/mysql/)
(文件名因操作系统而异。在 Linux 上 my.ini 实际上是位于目录 /etc/mysql/ 中的 my.cnf)
- Restart the service.
Create the
root
user (yes, a new userbecause what exists is 'root@localhost' which is local access only):CREATE USER 'root'@'%' IDENTIFIED BY '123';
Give the privileges:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
- 重新启动服务。
创建
root
用户(是的,一个新用户,因为存在的是'root@localhost',它只能是本地访问):CREATE USER 'root'@'%' IDENTIFIED BY '123';
给予特权:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
For DBAuser, add
WITH GRANT OPTION
at the end.e.g.
CREATE USER 'root'@'%' IDENTIFIED BY '123' WITH GRANT OPTION;
对于DBA用户,
WITH GRANT OPTION
在最后添加。例如
CREATE USER 'root'@'%' IDENTIFIED BY '123' WITH GRANT OPTION;
Because it does not work CREATE with GRANT?
因为它不适用于CREATE 与 GRANT?
MySQL 8can no longer create a user with GRANT
, so there is an error in IDENTIFIED BY '123'
if you try to use it with GRANT
, which is the most common error.
MySQL 8无法再创建用户 with GRANT
,因此IDENTIFIED BY '123'
如果您尝试将其与 一起使用GRANT
,则会出现错误,这是最常见的错误。
回答by Milan
For MySQL 8 open the mysqld.cnf file
对于 MySQL 8,打开 mysqld.cnf 文件
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
And modify or add the bind-addressoption:
并修改或添加bind-address选项:
[mysqld]
bind-address = 0.0.0.0
Restart the mysqlserver
重启mysql服务器
sudo service mysql restart