The database management functionality in PhpStorm is supported by the Database tools and SQL plugin. The Database tools and SQL plugin provides support of all the features that are available in DataGrip, the standalone database management environment for developers. With the plugin, you can query, create and manage databases. Databases can work locally, on a server, or in the cloud. The plugin supports MySQL, PostgreSQL, Microsoft SQL Server, SQLite, MariaDB, Oracle, Apache Cassandra, and others. See the full list of supported vendors in Database connection.
This section provides an overview of basic functionality that is available with the Database tools and SQL plugin. For more information about database features, see the official DataGrip documentation.
When you create a database connection, PhpStorm connects to a database automatically to receive database objects. The database management functionality in PhpStorm is supported by the Database tools and SQL plugin. The Database tools and SQL plugin provides support of all the features that are available in DataGrip, the standalone database management environment for developers. With the plugin, you can query, create and manage databases. Open your project in PhpStorm and open the DataSource window: Click on View - Tool Windows - Database Click on the Database sidebar, click on new - Datasource. PHP + JS(JQUERY + AJAX) + CSS + HTML + RESTful + MySQL - XAMP/UwAmp + PhpStorm. This is a great simple MVC skeleton in PHP that implements all the basic features of web programming. I couldn't find a great MVC skeleton without all the functions implemented so I uploaded mine. When I look at Editor Code Style SQL MySQL there are numerous pages that appear to have default values set. I see virtually the same thing in datagrip. The problem is that when I reformat a document using CTRL ALT L nothing happens to the SQL code. However, with datagrip CTRL ALT L reformats the SQL nicely. With PHPStorm, nothing changes.
Get started with database tools
These set of topics are focused on describing features, functionality, the application interface, and might help you to get started quickly.
Connect | Start working with your data source by creating a connection to it. |
Run a query | Connect an SQL file to a data source and run your code. |
View results | Connect an SQL file to a data source and run your code. |
Export/Import | Import and export your data to and from various formats with or without special tools like mysqldump, pg_dump, pg_restore, or psql. Also, you can have a look at the Export data in PhpStorm tutorial. |
LocalDB | Step-by-step tutorial how to create, connect, and start working with your SQL Server Express LocalDB instance. |
Microsoft SQL server | Tutorial shows you how to start working with Microsoft SQL server and connect to its instance with Windows domain or SQL Server authentication. |
Troubleshooting | Connectivity issue is a very common definition and might include many problems. This troubleshooting article will guide you through the most common steps to identify and fix the issue. If you could not find the answer, try to contact JetBrains and we can try to help you. |
Diagrams | Generate diagrams for database objects, build query and execution plans, generate flame graphs for EXPLAIN statements. |
There’s some info out there about connecting to MySQL via socket using something called junixsocket. All the instructions were pretty straight forward but I continued to get an error, something about socket length or some such thing.
Turns out we need a user with access via 127.0.0.1 so we can connect via port as opposed to socket.
MySQL 8 apparently no longer allows creating a user and granting privileges in a one-liner, so I did it in two.
I prefer issuing commands directly in MySQL as opposed to using the -e
command. so… mysql -u root
CREATEUSER ‘root’@’127.0.0.1’ IDENTIFIEDBY ‘root’;
GRANTALLON *.* TO ‘root’@’127.0.0.1’;
And for good measure:
FLUSH PRIVILEGES;
Now Local’s default user root, with default password ‘root’, can access MySQL using a port.
But Local doesn’t show a port for the site in the admin.
There’s some talk about finding the port in the address bar of Adminer, but for me that gave a different port that did not work in PhpStorm. Instead I got the port directly from MySQL:
- Right click the site in Local and click “Open Site Shell”.
mysql -u root
- Then issue the command
SHOW VARIABLES WHERE variable_name = 'port';
Now the MySQL Data Source can be added as it was in earlier versions of Local:
Phpstorm Sql
Phpstorm Phpunit
- Host: 127.0.0.1
- User: root
- Password: root
- Port: 10063 (from the example above)
- Database: local (optional)