php Mysql 与 Phpstorm IDE 的连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5673080/
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 Connection with Phpstorm IDE
提问by Sarmen B.
For those of you who are familiar with Phpstorm I am using version 2.0.1 as writing this question.
对于那些熟悉 Phpstorm 的人,我使用 2.0.1 版来写这个问题。
I am on a Mac using MAMP. I tried to connect my database with Phpstorm but it is a bit confusing.
我在使用 MAMP 的 Mac 上。我尝试将我的数据库与 Phpstorm 连接,但它有点令人困惑。
I went to tools-> data sourceswhen I press +to add
and choose db datasource
it wants me to enter a "jdbc://
" URL to the database.
当我按+添加并选择 db数据源时,我转到了工具->数据源,它希望我输入一个“ ” URL 到数据库。jdbc://
The whole time until now I've been using /Applications/MAMP/tmp/mysql/mysql.sock
.
直到现在我一直在使用/Applications/MAMP/tmp/mysql/mysql.sock
.
How do I get the db to connect with this socket thing? The software is amazing but confusing at times.
我如何让数据库与这个套接字连接?该软件很棒,但有时令人困惑。
采纳答案by prodigitalson
Well you could just use the JDBC connector. I have used with Eclipse in the past. Not familiar with PHP storm. Im not sure if it comes with MAMP so you may have to download and install it.
那么您可以只使用JDBC 连接器。我过去曾与 Eclipse 一起使用过。不熟悉PHP风暴。我不确定它是否带有 MAMP,因此您可能需要下载并安装它。
回答by Alex
On the top part of the add DB connection window choose MySQL, then click for download.
在添加数据库连接窗口的顶部选择 MySQL,然后单击下载。
Then you can use the connection string jdbc:mysql://localhost:3306/databasename
. The connection string format is also contained in the autocomplete of the input box.
然后就可以使用连接字符串了jdbc:mysql://localhost:3306/databasename
。连接字符串格式也包含在输入框的自动完成中。
回答by Maksim Kotlyar
I found this article useful: http://pro-cosmos.blogspot.com/2011/03/phpstorm-mysql.html
我发现这篇文章很有用:http: //pro-cosmos.blogspot.com/2011/03/phpstorm-mysql.html
I successfully configured phpstorm to work with mysql but I used "jdbc:mysql://localhost:3306as url.
我成功地将 phpstorm 配置为与 mysql 一起使用,但我使用了“jdbc:mysql://localhost:3306作为 url。
回答by brunettdan
Here's a screenshot of my settings.
这是我的设置的屏幕截图。
Thanks cweiske for 127.0.0.1, didn't work with localhost.
感谢 cweiske 提供 127.0.0.1,不适用于本地主机。
回答by Ma3x
The only thing you have to do is check the option "Allow network access to MySQL" inside the MySQL tab on MAMP (for your security, ensure you have the option "only from this Mac" selected).
您唯一需要做的就是选中MAMP 上 MySQL 选项卡内的“允许网络访问 MySQL”选项(为了您的安全,请确保您选择了“仅来自此 Mac”选项)。
回答by rich remer
You can't use Unix sockets with the standard JDBC driver. There's nothing about JDBC that prohibits writing a Unix socket driver, but I don't know of one.
您不能将 Unix 套接字与标准 JDBC 驱动程序一起使用。JDBC 没有任何内容禁止编写 Unix 套接字驱动程序,但我不知道一个。
Instead, you'll likely want to enable network connections in MySQL and use the following JDBC URL:
相反,您可能希望在 MySQL 中启用网络连接并使用以下 JDBC URL:
jdbc:mysql://localhost/mysql
jdbc:mysql://localhost/mysql
回答by cweiske
As a workaround, you could enable networked connections in mysql and connect to the database using the IP 127.0.0.1 in phpstorm.
作为一种解决方法,您可以在 mysql 中启用网络连接并使用 phpstorm 中的 IP 127.0.0.1 连接到数据库。
回答by neurobashing
As I understand it, JDBC does not support Unix domain sockets. You have to connect over TCP/IP.
据我了解,JDBC 不支持 Unix 域套接字。您必须通过 TCP/IP 进行连接。
回答by Антон Баранов
For socket connecting use a 8889 port. Example:
对于套接字连接,请使用 8889 端口。例子:
jdbc:mysql://localhost:8889/