mycli icon indicating copy to clipboard operation
mycli copied to clipboard

It doesn't work on Ubuntu on windows10.

Open byteroll opened this issue 7 years ago • 11 comments

I tried all methods in #456, but it doesn't work.

System: Ubuntu 18.04 bionic [Ubuntu on Windows 10]

I try mycli -S /var/run/mysqld/mysqld.sock -u root, but it responsed the msessage: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 2] Invalid argument)").

This is the ouput from the \s command.

mysql  Ver 14.14 Distrib 5.7.23, for Linux (x86_64) using  EditLine wrapper
Connection id:          15
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          less
Using outfile:          ''
Using delimiter:        ;
Server version:         5.7.23-0ubuntu0.18.04.1 (Ubuntu)
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:            /var/run/mysqld/mysqld.sock
Uptime:                 23 min 59 sec

Threads: 1  Questions: 29  Slow queries: 0  Opens: 107  Flush tables: 1  Open tables: 26  Queries per

byteroll avatar Sep 18 '18 11:09 byteroll

Hmm maybe because sockets are disabled for Windows: https://github.com/dbcli/mycli/blob/master/mycli/main.py#L405

meeuw avatar Sep 18 '18 16:09 meeuw

Hmm maybe because sockets are disabled for Windows: https://github.com/dbcli/mycli/blob/master/mycli/main.py#L405

Is that mean mycli will not work on WSL?

byteroll avatar Sep 19 '18 04:09 byteroll

I was wrong; sys.platform returns on WSL linux. So sockets should work. Could you please tell me how you've installed mysql-server on WSL? I've installed mysql using apt-get install mysql-server and started mysqld / mysqld_safe but it seems to stop after a few seconds.

meeuw avatar Sep 20 '18 19:09 meeuw

I was wrong; sys.platform returns on WSL linux. So sockets should work. Could you please tell me how you've installed mysql-server on WSL? I've installed mysql using apt-get install mysql-server and started mysqld / mysqld_safe but it seems to stop after a few seconds.

I use apt-get install mysql-server, and start service by service mysql start

byteroll avatar Sep 21 '18 06:09 byteroll

@GEeKkk I just reproduced this on WSL and was able to connect with:

$ mycli -u root -h 127.0.0.1

Can you see if that works for you?

tsroten avatar Oct 24 '18 03:10 tsroten

I was able to trace this error to the original exception:

~ $ mycli -S /var/run/mysqld/mysqld.sock -u root
Traceback (most recent call last):
  File "/home/tsr/.local/bin/mycli", line 11, in <module>
    sys.exit(cli())
  File "/home/tsr/.local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/tsr/.local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/tsr/.local/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/tsr/.local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/tsr/.local/lib/python2.7/site-packages/mycli/main.py", line 1114, in cli
    ssh_key_filename=ssh_key_filename
  File "/home/tsr/.local/lib/python2.7/site-packages/mycli/main.py", line 443, in connect
    _connect()
  File "/home/tsr/.local/lib/python2.7/site-packages/mycli/main.py", line 404, in _connect
    ssh_password, ssh_key_filename
  File "/home/tsr/.local/lib/python2.7/site-packages/mycli/sqlexecute.py", line 62, in __init__
    self.connect()
  File "/home/tsr/.local/lib/python2.7/site-packages/mycli/sqlexecute.py", line 118, in connect
    defer_connect=defer_connect
  File "/home/tsr/.local/lib/python2.7/site-packages/pymysql/__init__.py", line 94, in Connect
    return Connection(*args, **kwargs)
  File "/home/tsr/.local/lib/python2.7/site-packages/pymysql/connections.py", line 327, in __init__
    self.connect()
  File "/home/tsr/.local/lib/python2.7/site-packages/pymysql/connections.py", line 591, in connect
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 22] Invalid argument

I haven't had time to dig into the error though. Here are the connection details for reference:

 mycli.sqlexecute DEBUG - Connection DB Params:
        database: None
        user: u'root'
        host: u'localhost'
        port: 3306
        socket: u'/var/run/mysqld/mysqld.sock'
        charset: u'utf8'
        local_infile: False
        ssl: None
        ssh_user: None
        ssh_host: None
        ssh_port: 22
        ssh_password: None
        ssh_key_filename: None

It appears to happen on both Python 2 and 3.

tsroten avatar Oct 24 '18 03:10 tsroten

@GEeKkk I just reproduced this on WSL and was able to connect with:

$ mycli -u root -h 127.0.0.1

Can you see if that works for you? No, it doesn't work : ( image

byteroll avatar Nov 08 '18 11:11 byteroll

I tried connecting with:

$ mycli -S /var/run/mysqld/mysqld.sock -u root -h 127.0.0.1

It returns the following:

(1698, "Access denied for user 'root'@'localhost'")

nzec avatar Jul 18 '19 08:07 nzec

Same Problem with me 😥😥😥

guiaixiao avatar Feb 11 '20 09:02 guiaixiao

mycli doesn't work from wsl linux (ubuntu 18.04). i try to connect to my external mysql service but obtain : (9999, 'An internal error has occurred. Please retry or report your issues.\x00')

fle108 avatar Feb 27 '20 11:02 fle108

last wsl (Ubuntu) update : it works now

fle108 avatar Mar 11 '20 10:03 fle108