[WP Local & PHPStorm] - Connecting to MySQL using TCP/IP rather than a socket on macOS/Linux?
Steps Right-click on the site you wish to connect to via TCP/IP in Local’s sidebar and go to “Open Site Shell.”
Once your terminal opens, run the following commands:
Allow root to connect via 127.0.0.1.
mysql -e "CREATE USER 'root'@'127.0.0.1' IDENTIFIED BY 'root'; GRANT ALL ON . TO 'root'@'127.0.0.1';" Get the TCP/IP port that MySQL is currently running on. Note, this is not shown in Local’s UI as of writing if on macOS or Linux
mysql -e "SHOW VARIABLES WHERE Variable_name = 'port';" Here’s an example of what you should see after running these two commands:
Screen Shot 2020-07-31 at 10.02.05 AM Screen Shot 2020-07-31 at 10.02.05 AM 2036×240 62.8 KB Example: Connecting via PhpStorm Now that the user is created and you have the port, you can connect to it! Here’s what that looks like in PhpStorm.
Be sure that you use 127.0.0.1 as the “Host”, update “Port” to the port output in step #2 above, and set “Database” to local.