PyCharm: configure MySQL DB using "pipe"

Answered

Hi,

I am using a Windows 7 machine as a development platform for the moment.  I am running the latest PyCharm and am working on a python/Django project.  I have a local instance of MariaDB running but it is NOT using networking.  It is accepting connections through a named pipe/socket.

PyCharm keeps prompting me to configure data sources for this project but the MySQL and MaeiaDB dialogues only seem to support hostname and port number options.  Is there a way to have Pycharm either accept the named pipe I have setup or have it read the "my.cnf" config file that I have?

0
18 comments

Same thing for PhpStorm: need named pipe connection option for MySQL on Windows 10.

0
Avatar
Yuriy Vinogradov

Please read this article , here are the instructions how to make connection with JDBC driver and pipes.

To  find socketFactory propertie please go to DataSource properties -> Advanced.

 

0

Yuriy, I followed the instructions and now I get an error:

[08S01][1043] Bad handshake.

Here are the exact steps I've made:

1. Open the data source's properties
(go to main menu, open View -> Tool Windows -> Database, select the source, press Shift+Enter)

2. In the General tab enter the following URL value: 

jdbc:mysql://address=(protocol=pipe)

3. In the Advanced tab find socketFactory property and set it's value to

com.mysql.cj.protocol.NamedPipeSocketFactory

4. Press Test Connection. Ends up with the error.

You can see all the steps on the screenshots:

I use latest version of PhpStorm (2021.2.3 at the time), latest verison of MySQL Connector/J (8.0.25 at the time) and MySQL Server 8.0.22.
(In the tool window MySQL Server's version somewhy shows up as 5.7.26, which is wrong and likely comes from partially successful connection tries in the past.)

The server instance itself is 100% fine: I connect to it via the pipe with various other clients on a regular basis.

0

I've read the instruction.

Eventually changes I had to make come down to these:

1. Set Host field value to

(protocol=pipe)(path=\\.\pipe\MySQL)

2. Set URL field value to

jdbc:mysql://(protocol=pipe)(path=\\.\pipe\MySQL)/

(It actually sets up automatically if you clear the field before setting Host value)

I'm still getting the same "[08S01][1043] Bad handshake" error.

(screenshot: https://intellij-support.jetbrains.com/hc/user_images/TUTYS0eHN_O4asyjySFVkA.png)

I've also tried values without (path=\\.\pipe\MySQL) in both fields. Still no good.

 

Also I wasn't able to complete step 4 of the instruction:

On the Advanced tab, find the serverTimezone parameter in the list of options. Double-click the Value cell and type your server timezone (for example, UTC).

Because there is no such variable in the list (sessionVariables goes immediately after serverRSAPublicKeyFile).

(screenshot: https://intellij-support.jetbrains.com/hc/user_images/XcuipOY8QchkpQqjBRFJ3g.png)

   
0

Please set 'Connection type' to 'Unix socket' here

0

Please set 'Connection type' to 'Unix socket' here

Will this work on Windows 10 machine?

0

Please set 'Connection type' to 'Unix socket' 

What value should I set the URL field to? It stays the same after I changed the connection type, but it apparently shouldn't be like that.

0

Yes my bad, it won't work on Windows.

Please try to switch driver to 'MySQL for 5.1' or use any other version of 8.x.

BTW what is the usecase for pipe connection? Don't you want to enable TCP/IP?

0

Please try to switch driver to 'MySQL for 5.1' or use any other version of 8.x.

No good. Yields whether the same error or even worst ones.

BTW what is the usecase for pipe connection?

All database server's clients run at the same machine, so there is no need of any network connections.

Don't you want to enable TCP/IP?

No, I don't, because it decreases security. 
There is actually no reason for that except JetBrains not working properly.

0

I wonder if there is anyone in JetBrains team who actually does have installation of MySQL server on Windows (standalone, not in Docker) and can reproduce steps I make.

0

Have you set up MySQL properly to accept piped connections?

0

Have you set up MySQL properly to accept piped connections?

Yes, I have.

I connect to it via pipe with various clients: PHP, mysql command line client, MySQL Workbench.

All of them work fine.

0

Could you share output for

SHOW GLOBAL VARIABLES LIKE 'named_pipe'

?

0
mysql> SHOW GLOBAL VARIABLES LIKE 'named_pipe';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| named_pipe    | ON    |
+---------------+-------+
1 row in set (0.00 sec)
1

I see, it looks like an issue then. Could you file an issue in DataGrip YouTrack?

0

Make sure you've configured your MySQL server correctly since I can't reproduce the issue.


Please, follow the instruction https://www.jetbrains.com/help/datagrip/how-to-connect-to-mysql-with-named-pipes.html but skip serverTimeZone section.

0

Please sign in to leave a comment.