dbcli / mycli

A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.
http://mycli.net
Other
11.32k stars 656 forks source link

odd login problem with ssl #1092

Open dougmccasland opened 1 year ago

dougmccasland commented 1 year ago

I started seeing this error a month or two ago, when running mycli on the server:

% mycli -u myuser
Connecting to socket /var/run/mysqld/mysqld.sock, owned by user mysql
[Errno 13] Permission denied

Similar response with mycli -u root (as user root).

The .mycli.log showed:

2022-10-23 12:32:15,299 (279176/MainThread) mycli.config WARNING - Unable to parse line None of config file '/etc/mysql/my.cnf'.
2022-10-23 12:32:15,299 (279176/MainThread) mycli.config WARNING - Using successfully parsed config values.
2022-10-23 12:32:15,300 (279176/MainThread) mycli.config WARNING - Unable to parse line None of config file '/etc/mysql/conf.d/mysqldump.cnf'.
2022-10-23 12:32:15,300 (279176/MainThread) mycli.config WARNING - Using successfully parsed config values.
2022-10-23 12:32:15,302 (279176/MainThread) mycli.config WARNING - Unable to parse line None of config file '/etc/mysql/my.cnf'.
2022-10-23 12:32:15,302 (279176/MainThread) mycli.config WARNING - Using successfully parsed config values.
2022-10-23 12:32:15,303 (279176/MainThread) mycli.config WARNING - Unable to parse line None of config file '/etc/mysql/conf.d/mysqldump.cnf'.
2022-10-23 12:32:15,303 (279176/MainThread) mycli.config WARNING - Using successfully parsed config values.
2022-10-23 12:32:15,309 (279176/MainThread) mycli.main
ERROR - traceback: 'Traceback (most recent call last):\n  File
  "/usr/lib/python3/dist-packages/mycli/main.py", line 482, in connect\n
  _connect()\n  File "/usr/lib/python3/dist-packages/mycli/main.py",
  line 456, in _connect\n    self.sqlexecute = SQLExecute(\n
  File "/usr/lib/python3/dist-packages/mycli/sqlexecute.py",
  line 119, in __init__\n    self.connect()\n  File
  "/usr/lib/python3/dist-packages/mycli/sqlexecute.py",
  line 179, in connect\n    conn = pymysql.connect(\n  File
  "/usr/lib/python3/dist-packages/pymysql/connections.py", line 285,
  in __init__\n    self.ctx = self._create_ssl_ctx(ssl)\n  File
  "/usr/lib/python3/dist-packages/pymysql/connections.py", line
  387, in _create_ssl_ctx\n    ctx.load_cert_chain(sslp["cert"],
  keyfile=sslp.get("key"))\nPermissionError: [Errno 13] Permission denied\n'

indicating some SSL cert problem. Since I didn't care about SSL in this case and just wanted to connect via mysqld.sock, I opened sqlexecute.py in /usr/lib/python3/dist-packages/mycli and edited this line

conn = pymysql.connect(
            database=db, user=user, password=password, host=host, port=port,
            unix_socket=socket, use_unicode=True, charset=charset,
            autocommit=True, client_flag=client_flag,
            local_infile=local_infile, conv=conv, ssl=ssl, program_name="mycli",
            defer_connect=defer_connect, init_command=init_command
        )

changing ssl=ssl to ssl=''. This fixed the problem, but obviously not a permanent fix.

Is this a bug, or is my system misconfigured? No trouble with anything else on the system, including SSL.

Server: Ubuntu 22.04, mysqld Ver 8.0.30-0ubuntu0.22.04.1 for Linux