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

Can't connect to mysql on new install? #506

Closed
5 tasks done
zack6849 opened this issue Feb 15, 2019 · 6 comments
Closed
5 tasks done

Can't connect to mysql on new install? #506

zack6849 opened this issue Feb 15, 2019 · 6 comments

Comments

@zack6849
Copy link
Contributor

zack6849 commented Feb 15, 2019

ISSUE TYPE

  • Bug Report

Checklist

  • .env file is attached
  • docker-compose.override.yml is attached (if it exists)
  • Custom configs from cfg/ dir are attached (if customized)
  • docker-compose logs and log/ output is added
  • I've looked through the docs: https://devilbox.readthedocs.io/en/latest/

I've looked through existing issues: https://github.com/cytopia/devilbox/issues

OS / ENVIRONMENT

  1. Host operating system and version: Arch Linux 4.20.8-arch1-1-ARCH
  2. Docker version: Docker version 18.09.2-ce, build 62479626f2
  3. Docker Compose version: docker-compose version 1.23.2, build 1110ad01
  4. (Linux) Is SELinux enabled?: No
  5. What git commit hash are you on?: cc6de2d

SUMMARY

STEPS TO REPRODUCE

Clone the repo, start the project, and try to connect to mysql.

EXPECTED BEHAVIOUR

MySQL is up and accessible

ACTUAL BEHAVIOUR

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")

⋊> ~ git clone https://github.com/cytopia/devilbox.git; cd devilbox; cp env-example .env; docker-compose up -d                                                                                                                      11:37:25
Cloning into 'devilbox'...
remote: Enumerating objects: 18633, done.
remote: Total 18633 (delta 0), reused 0 (delta 0), pack-reused 18633
Receiving objects: 100% (18633/18633), 31.08 MiB | 6.22 MiB/s, done.
Resolving deltas: 100% (8063/8063), done.
Creating network "devilbox_app_net" with driver "bridge"
Creating devilbox_bind_1 ... done
Creating devilbox_php_1  ... done
Creating devilbox_httpd_1 ... done
Creating devilbox_memcd_1 ... done
Creating devilbox_redis_1 ... done
Creating devilbox_mongo_1 ... done
Creating devilbox_mysql_1 ... done
Creating devilbox_pgsql_1 ... done
⋊> ~/devilbox on master ◦ ./shell.sh                                                                                                                                                                                                11:37:57

------------------------------------------------------------------------------------------
                              _            _ _ _               
                             | |          (_) | |              
                           __| | _____   ___| | |__   _____  __
                          / _` |/ _ \ \ / / | | '_ \ / _ \ \/ /
                         | (_| |  __/\ V /| | | |_) | (_) >  < 
                          \__,_|\___| \_/ |_|_|_.__/ \___/_/\_\
                                                               
                                  http://devilbox.org
                            https://devilbox.readthedocs.io



                                    Available Tools
          https://devilbox.readthedocs.io/en/latest/readings/available-tools.html

                           How to work inside this PHP container
 https://devilbox.readthedocs.io/en/latest/intermediate/work-inside-the-php-container.html



                    | Available Dirs   | Description                  |
                    |------------------|------------------------------|
                    | /shared/httpd    | Project base directory       |
                    | /shared/backups  | Backup directory             |
                    | /var/mail        | Email directory              |
                    | /var/log         | Log file directory           |

------------------------------------------------------------------------------------------

[email protected] in /shared/httpd $ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")
[email protected] in /shared/httpd $ 

OTHER INFORMATION

Start command

$ docker-compose up -d

File and user permissions (Linux & MacOS)

uid=1000(zack) gid=974(docker) groups=974(docker),998(wheel),1000(zack)
$ ls -la
drwxr-xr-x  4 zack docker  4096 Feb 15 11:37 .devilbox/
⋊> ~/devilbox on master ◦ ls -la data/www/                                                                                                                                                                                          11:40:39
total 8
drwxr-xr-x 2 zack zack   4096 Feb 15 11:37 ./
drwxr-xr-x 7 zack docker 4096 Feb 15 11:37 ../
-rw-r--r-- 1 zack docker    0 Feb 15 11:37 .keepme

logs.tar.gz
docker-compose-log.txt=

@zack6849 zack6849 added the bug label Feb 15, 2019
@cytopia
Copy link
Owner

cytopia commented Feb 16, 2019

@zack6849 MySQL is not running inside the PHP container. You should use:

 mysql -u root -h mysql -p

Info:

When not specifying -h mysql (The host to use, which in this case is called mysql), then the connection defaults to use the local MySQL socket instead of doing a TCP connection. As no MySQL socket is present on the PHP container, the connection will fail. So to overcome this, you must explicitly tell it, to which host to connect.

@cytopia cytopia self-assigned this Feb 16, 2019
@cytopia cytopia added invalid and removed bug labels Feb 16, 2019
@cytopia cytopia closed this as completed Feb 16, 2019
@pnoeric
Copy link
Contributor

pnoeric commented Mar 15, 2019

FWIW I had exactly the same problem. Happy to find this solution here! The whole Docker thing is awfully confusing for those of us who do not have a lot of experience with it (which is devilbox's target audience, I think). Might be worth mentioning this in the docs.

@cytopia
Copy link
Owner

cytopia commented Mar 15, 2019

@pnoeric Unfortunately for me it is quite obvious and I am unsure how to best formulate it that it is easy to grasp right from the very beginning. Do you have some description in mind that would have made it very obvious to you?

@pnoeric
Copy link
Contributor

pnoeric commented Mar 17, 2019

I would just put a couple of lines in the docs somewhere around where you "use" devilbox (maybe by the part about shell.sh) - "if you want to connect to the MySQL server directly from inside the container, you have to use this special command (so Docker knows to find the server over in its separate, special container)." Something like that. ;-)

I find myself often running shell.sh to drop in and then look at the MySQL server directly from there... so I was stuck until I found this.

Again, I suggest this only because I think your target audience for devilbox seems to be folks (like me) who aren't experts at Docker, so these folks don't really understand the concept of separate-but-linked containers for the various services.

@cytopia
Copy link
Owner

cytopia commented Mar 24, 2019

I have rewritten the documentation and hope it does no present what actually needs to be done in Release v1.0.1

https://github.com/cytopia/devilbox/releases/tag/v1.0.1

@dmorbidi
Copy link

dmorbidi commented Feb 7, 2022

@cytopia, is it possible to overcome the issue by specifying the MySQL host in a cnf file? Like host=mysql. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants