连接到本地网络上的 MySQL 数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30190116/
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
Connect to MySQL Database on Local Network
提问by ErrorNotFoundException
I actually thought I could do this until I tried. I installed MySQL server on one PC in the Local network IP Address (192.168.1.4) and now I am trying to access it from another PC in the same network (192.168.1.5) but I am unable:
在我尝试之前,我实际上认为我可以做到这一点。我在本地网络 IP 地址 (192.168.1.4) 的一台 PC 上安装了 MySQL 服务器,现在我试图从同一网络 (192.168.1.5) 中的另一台 PC 访问它,但我无法:
C:\Users\DOMICO>mysql -u domico -h 192.168.1.4 -p
Enter password: **********
ERROR 1045 (28000): Access denied for user 'domico'@'DOMICO-PC' (using password:
YES)
Surprisingly DOMICO-PC is the PC I am trying to connect from. Why is it not connecting to the given host but trying to connect to Local machine?
令人惊讶的是,DOMICO-PC 是我尝试连接的 PC。为什么它没有连接到给定的主机而是尝试连接到本地机器?
回答by Vinoth Ramamoorthy
You need to give permissions to connect from remotehost
您需要授予从远程主机连接的权限
mysql>GRANT ALL PRIVILEGES ON database.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
mysql>GRANT ALL PRIVILEGES ON database.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
回答by Ashley Jordan
This is connecting to the intended host as you require it to. t is just stating who is connecting. and where from.
这是根据您的需要连接到目标主机。t 只是说明谁在连接。和从哪里来。
USER@DOMAIN
用户@域
user : your user running the mysql command domain : name of the system you are connecting from.
用户:您运行 mysql 命令的用户 domain:您正在连接的系统的名称。
Log into mysql via the server using -u root, ensure the user 'domico' is created and has sufficient access.
使用 -u root 通过服务器登录 mysql,确保用户 'domico' 已创建并具有足够的访问权限。
回答by Tom
You need to have proper permissions to connect. In the computer that has the DB installed, give your user the proper permissions:
您需要有适当的权限才能连接。在安装了 DB 的计算机上,为您的用户授予适当的权限:
mysql>GRANT ALL PRIVILEGES ON *.* TO 'domico'@'DOMICO-PC';
mysql>FLUSH PRIVILEGES;
You can read more here: https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql
您可以在此处阅读更多信息:https: //www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql
And here: https://dev.mysql.com/doc/refman/5.1/en/privileges-provided.html
在这里:https: //dev.mysql.com/doc/refman/5.1/en/privileges-provided.html
回答by Basit
creata a new user by mysql server and give it privileges you can do it by command and by using any server e.g by using workbench
通过 mysql 服务器创建一个新用户并授予它特权,您可以通过命令和使用任何服务器(例如使用工作台)来完成
回答by Vitalie
For all users and all host.
适用于所有用户和所有主机。
mysql -u root -p
GRANT ALL PRIVILEGES
ON *.*
TO '%'@'%'
IDENTIFIED BY 'password'
WITH GRANT OPTION;
FLUSH PRIVILEGES;
QUIT;