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

Error connection to database: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) #743

Closed
kaykhan opened this issue Jun 27, 2022 · 15 comments · Fixed by #753
Labels

Comments

@kaykhan
Copy link

kaykhan commented Jun 27, 2022

Hi, im having an issue with using the tool when i exec it with a config file

 mydumper --defaults-file config.cnf                            
** (mydumper:2333973): WARNING **: 17:44:15.277: Using trx_consistency_only, binlog coordinates will not be accurate if you are writing to non transactional tables.

** (mydumper:2333973): CRITICAL **: 17:44:15.281: Error connection to database: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

config.cnf

[mydumper]
database=<redacted>
host=<redacted>
port=3306
user=dba
password=<redacted>
compress=1
build-empty-files=1
complete-insert=1
threads=16
trx-consistency-only=1

[mydumper_variables]
max_execution_time=0

if i use it by passsing the params in the cli, it works

mydumper --host <redacted> --user dba --password <redacted> --verbose 3 --database <redacted> --complete-insert --build-empty-files --compress --threads 16 --trx-consistency-only

Can someone tell me what im doing wrong in my config file? My host is a url to aws rds if that makes a difference

mydumper --version
mydumper 0.12.3-3, built against MySQL 8.0.29

@davidducos
Copy link
Member

Hi @kaykhan,
Can you Rea with the absolute file name ?

@kaykhan
Copy link
Author

kaykhan commented Jun 27, 2022

Hi @kaykhan, Can you Rea with the absolute file name ?

config.cnf is within the directory im running mydumper from

@kaykhan
Copy link
Author

kaykhan commented Jun 27, 2022

Hi @kaykhan, Can you Rea with the absolute file name ?

maybe i misread what youre asking me to try? what is "Rea?"

@davidducos
Copy link
Member

Hi @kaykhan, I know that the file is in the current directory, but can you try with the absolute file name anyways? Can you use quotes (") between de file name?

@kaykhan
Copy link
Author

kaykhan commented Jun 27, 2022

Hi @kaykhan, I know that the file is in the current directory, but can you try with the absolute file name anyways? Can you use quotes (") between de file name?

I tried with quotes it did not work

mydumper --defaults-file="config.cnf"

Is this what you mean by specify the aboslute name? (sorry its late here)

[~/checkpoint/services/mysql/backup] mydumper --defaults-file="~/checkpoint/services/mysql/backup/config.cnf"

** (mydumper:436318): WARNING **: 22:44:09.496: Failed to load config file ~/checkpoint/services/mysql/backup/config.cnf: No such file or directory

** (mydumper:436318): CRITICAL **: 22:44:09.499: Error connection to database: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

@kaykhan
Copy link
Author

kaykhan commented Jun 28, 2022

@davidducos any ideas what might be happening here?

@kaykhan
Copy link
Author

kaykhan commented Jun 28, 2022

I dont think there is anything wrong with it recogizing the .cnf file because you can see the warning message:

** (mydumper:2333973): WARNING **: 17:44:15.277: Using trx_consistency_only, binlog coordinates will not be accurate if you are writing to non transactional tables.

Its definatly reading the .cnf file because otherwise it would not know i have set trx_consistency_only

I believe the issue might be to do with the host value host=mysql.acme.com


Doing some testing, i found another way to trigger this error in myloader if i set the host=localhost, i get the same Can't connect to local MySQL server through socket '/tmp/mysql.sock' error. If i use host=127.0.0.1 it connects. I dont know if that helps in anyway

@peng19832
Copy link

When using the command line to connect to mysql through localhost, the socket path will be obtained from the default configuration file below, Otherwise, if the socket path is not explicitly specified and the path is not found in these files, the hardcoded path will be used "/tmp/mysql.sock":
/etc/my.cnf /etc/mysql/my.cnf ${MYSQL HOME}/etc/my.cnf

When the IP is specified, the connection is made through the tcp/ip protocol instead of the socket. The two methods are different.

@kaykhan
Copy link
Author

kaykhan commented Jul 1, 2022

@peng19832 Sorry, im confused what you are telling me to do?

Just to clarify, i am not connecting to localhost and im still getting the error.

@davidducos
Copy link
Member

@kaykhan The configuration file is read by mydumper and by the mysql api, please use the absolute file name to confirm that it is not your issue.

@kaykhan
Copy link
Author

kaykhan commented Jul 1, 2022

@kaykhan The configuration file is read by mydumper and by the mysql api, please use the absolute file name to confirm that it is not your issue.

You can see in my previous message i have tried that?

Is this what you mean by specify the aboslute name? (sorry its late here)

[~/checkpoint/services/mysql/backup] mydumper --defaults-file="~/checkpoint/services/mysql/backup/config.cnf"

** (mydumper:436318): WARNING **: 22:44:09.496: Failed to load config file ~/checkpoint/services/mysql/backup/config.cnf: No such file or directory

** (mydumper:436318): CRITICAL **: 22:44:09.499: Error connection to database: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

@davidducos
Copy link
Member

Try one more time without using ~, full absolute location. And you should also test it only using host, port, user and password,and remove the other options.

@kaykhan
Copy link
Author

kaykhan commented Jul 1, 2022

[mydumper]
database=<redacted>
host=mysql.<redacted>.com
port=3306
user=dba
password=<redacted>

image

update:

this worked :/ but kind of awkward to run it like this

mydumper --defaults-file="checkpoint/services/mysql/mysqldump/login.cnf"

@kaykhan kaykhan closed this as completed Jul 1, 2022
@davidducos
Copy link
Member

Hi @kaykhan,
Agree, but that is how the mysql api works, we need to a add some checks on mydumper side to send the path in the way that the mysql api understands. I'm going to open this to work on this issue.

@davidducos davidducos reopened this Jul 1, 2022
@davidducos
Copy link
Member

We might be using https://docs.gtk.org/glib/func.canonicalize_filename.html to get the absolute filename for --defaults-file. It will be useful for MySQL API and to check if the file exists

@davidducos davidducos added the bug label Jul 5, 2022
@davidducos davidducos added this to the Release 0.12.5-1 milestone Jul 5, 2022
@davidducos davidducos linked a pull request Jul 12, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants