开发者

Mysql Connection with Phpstorm IDE

For those of you who are familiar with Phpstorm I am using version 2.0.1 as writing this question.

I am on a Mac using MAMP. I tried to connect my database with Phpstorm but it is a bit confusing.

I went to tools -> data sources when I press + to add and choose db datasource it wants me to enter a "jdbc://" URL to the database.

The whole time until now I've been using /Applications/MAMP/tmp/mysql/mysql.sock.

How do开发者_如何学Go I get the db to connect with this socket thing? The software is amazing but confusing at times.


On the top part of the add DB connection window choose MySQL, then click for download.

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.


I found this article useful: http://pro-cosmos.blogspot.com/2011/03/phpstorm-mysql.html

I successfully configured phpstorm to work with mysql but I used "jdbc:mysql://localhost:3306 as url.


Here's a screenshot of my settings.

Thanks cweiske for 127.0.0.1, didn't work with localhost.

Mysql Connection with Phpstorm IDE


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).

Here is a screenshot of the setting


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.


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.

Instead, you'll likely want to enable network connections in MySQL and use the following JDBC URL:

jdbc:mysql://localhost/mysql


As a workaround, you could enable networked connections in mysql and connect to the database using the IP 127.0.0.1 in phpstorm.


As I understand it, JDBC does not support Unix domain sockets. You have to connect over TCP/IP.


For socket connecting use a 8889 port. Example:

jdbc:mysql://localhost:8889/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜