Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect without specifying the port number #192

Closed
haidaraM opened this issue Nov 9, 2015 · 16 comments

Comments

@haidaraM
Copy link

@haidaraM haidaraM commented Nov 9, 2015

I don't know if this is really a bug or if I missed something but I tried to connect to a database without specifying the port number and I got the following errror :
%d format: a number is required, not str . The command was mycli -h x.x.x.x -u remote_user where x.x.x.x is an ip address. After I put the port number and it worked.

If I must specify the port number, I think the error message can be more explicit.

I'm using mycli 1.5.0

@amjith

This comment has been minimized.

Copy link
Member

@amjith amjith commented Nov 10, 2015

It is a bug that was recently introduced in 1.5.0. We'll fix this ASAP.

Thank you for reporting.

@haidaraM

This comment has been minimized.

Copy link
Author

@haidaraM haidaraM commented Nov 10, 2015

Cool.

@amjith

This comment has been minimized.

Copy link
Member

@amjith amjith commented Nov 10, 2015

Can you tell me the exact command you used that failed? I'm unable to reproduce the error you're seeing.

@haidaraM

This comment has been minimized.

Copy link
Author

@haidaraM haidaraM commented Nov 10, 2015

mysql -h 192.168.33.10 -u remote_user. The ip address is the address of a VM on which I installed mysql and configured it to allow remote access.

@amjith

This comment has been minimized.

Copy link
Member

@amjith amjith commented Nov 10, 2015

Here's an example of what I tried:

↪ mycli -h 192.168.99.100 -u root
(2003, "Can't connect to MySQL server on u'192.168.99.100' ([Errno 61] Connection refused)")
@haidaraM

This comment has been minimized.

Copy link
Author

@haidaraM haidaraM commented Nov 10, 2015

I don't know what is your configuration but I have a similar error if i try to connect with an user who is not allowed to connect remotely. In my case the root user is not allowed, just the remote_user.

@haidaraM haidaraM changed the title Connect without specify the port number Connect without specifying the port number Nov 10, 2015
@amjith

This comment has been minimized.

Copy link
Member

@amjith amjith commented Nov 10, 2015

Can you post the error messages from both mysql and mycli when you try to connect without the port number?

I'd like to see the error message from both programs.

@haidaraM

This comment has been minimized.

Copy link
Author

@haidaraM haidaraM commented Nov 10, 2015

The error and general logs of mysql didn't change when I try to connect without the port number.

mycli showed the following error : %d format: a number is required, not str with the same command I posted.

So I think error is in mycli because It looks like mysql has not received the request.

@amjith

This comment has been minimized.

Copy link
Member

@amjith amjith commented Nov 10, 2015

Can you run pip freeze and paste the output here? You're right that the error is coming from mycli and it's not even making a call to mysql instance. But the fact that I'm not able to reproduce it is very confusing. So I'd like to see if there is a mismatch in some of dependencies.

@haidaraM

This comment has been minimized.

Copy link
Author

@haidaraM haidaraM commented Nov 10, 2015

Django==1.8.2
Mako==0.9.1
MarkupSafe==0.18
Pillow==2.8.2
PyMySQL==0.6.7
Pygments==1.6
Send2Trash==1.3.0
apturl==0.5.2ubuntu4
certifi==14.05.14
chardet==2.2.1
checkbox-ng==0.3
checkbox-support==0.2
click==4.1
colorama==0.2.5
command-not-found==0.3
configobj==5.0.6
daemonocle==0.8
defer==1.0.6
feedparser==5.1.3
friends==0.1
google-api-python-client==1.4.1
html5lib==0.999
httplib2==0.8
language-selector==0.1
louis==2.5.3
lxml==3.3.3
menulibre==2.0.4
mycli==1.5.0
mysqlclient==1.3.6
oauth2client==1.4.12
oauthlib==0.6.1
onboard==1.0.1
oneconf==0.3.7.14.04.1
pgcli==0.19.1
piston-mini-client==0.7.5
plainbox==0.5.3
prompt-toolkit==0.46
psutil==2.1.1
psycopg2==2.6.1
pyasn1==0.1.8
pyasn1-modules==0.0.6
pycrypto==2.6.1
pycurl==7.19.3
pygobject==3.12.0
pyparsing==2.0.1
python-apt==0.9.3.5ubuntu1
python-debian==0.1.21-nmu2ubuntu2
pyxdg==0.25
requests==2.2.1
rsa==3.1.4
simplejson==3.8.0
six==1.5.2
software-center-aptd-plugins==0.0.0
sqlparse==0.1.18
ubuntu-drivers-common==0.0.0
ufw==0.34-rc-0ubuntu2
unattended-upgrades==0.1
unity-scope-audacious==0.1
unity-scope-calculator==0.1
unity-scope-chromiumbookmarks==0.1
unity-scope-clementine==0.1
unity-scope-colourlovers==0.1
unity-scope-devhelp==0.1
unity-scope-firefoxbookmarks==0.1
unity-scope-gdrive==0.7
unity-scope-gmusicbrowser==0.1
unity-scope-gourmet==0.1
unity-scope-guayadeque==0.1
unity-scope-manpages==0.1
unity-scope-musique==0.1
unity-scope-openclipart==0.1
unity-scope-texdoc==0.1
unity-scope-tomboy==0.1
unity-scope-virtualbox==0.1
unity-scope-yelp==0.1
unity-scope-zotero==0.1
unity-tweak-tool==0.0.6
uritemplate==0.6
urllib3==1.7.1
usb-creator==0.2.23
wcwidth==0.1.4
wheel==0.24.0
xdiagnose==3.6.3build2
xkit==0.0.0
@amjith

This comment has been minimized.

Copy link
Member

@amjith amjith commented Nov 10, 2015

I'm using the same versions and I'm still unable to reproduce it. There are a couple more things I'd like to ask.

  1. Do you have a ~/.my.cnf file or a /etc/my.cnf file in your system? Can you paste the non-sensitive portions of that file?
  2. Can you try installing version 1.4.0 of mycli (using pip install mycli==1.4.0)? I'd like to confirm that this was introduced in 1.5.0.

Thank you!

@haidaraM

This comment has been minimized.

Copy link
Author

@haidaraM haidaraM commented Nov 10, 2015

I think the bug was introduced in 1.5.0. I installed the version 1.4.0 and I can connect without the port number : mycli -h 192.168.33.10 -u remote_user

Otherwise this my my.cnf :

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0

[mysqld]
#
# * Basic Settings
#
user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address        = 0.0.0.0
#
# * Fine Tuning
#
key_buffer      = 16M
max_allowed_packet  = 16M
thread_stack        = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit   = 1M
query_cache_size        = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
general_log_file        = /var/log/mysql/mysql.log
general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#log_slow_queries   = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id      = 1
#log_bin            = /var/log/mysql/mysql-bin.log
expire_logs_days    = 10
max_binlog_size         = 100M
#binlog_do_db       = include_database_name
#binlog_ignore_db   = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem



[mysqldump]
quick
quote-names
max_allowed_packet  = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer      = 16M

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/

@amjith

This comment has been minimized.

Copy link
Member

@amjith amjith commented Nov 11, 2015

I've reproduced it locally. Looks like the presence of port number in my.cnf file was causing this error.

I'll fix it soon.

@amjith

This comment has been minimized.

Copy link
Member

@amjith amjith commented Nov 11, 2015

I've created a pr to fix this issue #193.

In the meantime you can install the fix from the branch by using the following command:

pip install -U https://github.com/dbcli/mycli/archive/amjith/fix_cnf_file_port_bug.zip

That will help me confirm that the fix works.

@haidaraM

This comment has been minimized.

Copy link
Author

@haidaraM haidaraM commented Nov 11, 2015

The fix works. I can connect without the port number. 👍

@mdsrosa

This comment has been minimized.

Copy link
Contributor

@mdsrosa mdsrosa commented Nov 11, 2015

This has been fixed by #193. Thanks, @amjith!

@haidaraM Thank you for reporting it. Cheers! 😄

@mdsrosa mdsrosa closed this Nov 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.