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

Illuminate\Database\QueryException #25

Closed
justoX opened this issue Apr 24, 2018 · 23 comments
Closed

Illuminate\Database\QueryException #25

justoX opened this issue Apr 24, 2018 · 23 comments
Assignees
Labels

Comments

@justoX
Copy link

justoX commented Apr 24, 2018

When I run $ docker-compose run --rm blog-server php artisan migrate , the first step of the 'Before Starting' section I get the following error message:
Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = laravel-blog and table_name = migrations) at /application/vendor/laravel/framework/src/Illuminate/Database/Connection.php: 664

I'm using Valet.

@guillaumebriday
Copy link
Owner

Hey ! Did you follow steps in the Installation section before ?

Especially this one cp .env.example .env ?

@justoX
Copy link
Author

justoX commented Apr 24, 2018 via email

@justoX
Copy link
Author

justoX commented Apr 24, 2018

image

@guillaumebriday
Copy link
Owner

Ok, I've just tried and I have the same error. I think it's because mysql is not ready to handle connection. I've retried the command 3 times and it worked.

I will check how to fix this, thanks !

@justoX
Copy link
Author

justoX commented Apr 24, 2018

Ok, let me try again. I also ran multiple times to no success. Thank you.

@guillaumebriday
Copy link
Owner

guillaumebriday commented Apr 24, 2018

@guillaumebriday
Copy link
Owner

I don't like the workarounds that much but PR are welcome.

To use it until the fix, just run docker-compose up -d before the migration

@justoX
Copy link
Author

justoX commented Apr 24, 2018 via email

@justoX
Copy link
Author

justoX commented Apr 24, 2018 via email

@justoX
Copy link
Author

justoX commented Apr 24, 2018

Result of running docker-compose up -d
image
mysql is definitely the culprit.

@tompenzer
Copy link
Contributor

tompenzer commented May 11, 2018

I don't think people can make branches or pull requests for this project, but I was able to get a fresh clone of master to work after changing the docker-compose.yml file to set mysql and mysql-test containers to specify the mysql:5.7 image rather than just mysql (I was having authentication issues with mysql 8.x that was getting pulled via mysql:latest), which I now see was fixed shortly after a cloned the repo a few days ago. I also noticed missing string enclosure single quotes for the port number on the echo-server container config [1], but don't know if that had any effect on getting it running properly.

One thing I'll note is I had to delete the (gitignored) contents of /storage/tmp/ in order for the mysql downgrade to work properly, in case you cloned and built the project before pulling the latest version of master. Also, the first attempt at migration/seeding got a PDO error, but a second attempt shortly after worked for me.

[1] https://github.com/guillaumebriday/laravel-blog/blob/master/docker-compose.yml#L59

@guillaumebriday
Copy link
Owner

Hey ! Yep I had the issue with the latest version of the mysql image and i had to remove /storage/tmp.

The support of mysql 8 is effective since this commit laravel/framework#23948 available in the 5.6.18. I need to upgrade the laravel version and try to upgrade the mysql too to check if it does not break anything.

And yes the single quotes change nothing in the docker-compose.yml but I will add for consistency, thanks !

@guillaumebriday
Copy link
Owner

guillaumebriday commented May 11, 2018

The documentation as a note about string interpolation for ports https://docs.docker.com/compose/compose-file/#ports

Note: When mapping ports in the HOST:CONTAINER format, you may experience erroneous results when using a container port lower than 60, because YAML parses numbers in the format xx:yy as a base-60 value. For this reason, we recommend always explicitly specifying your port mappings as strings.

Even if I don't use port lower than 60 I will follow the documentation with double quotes everywhere

Commit : 73be5b8

@prashantidealittechno
Copy link

Please try to ssh into docker and then run command composer dump

    $ composer dump

and clear config with below command

    $ php artisan config:clear 

and then check again it should work.

@guillaumebriday
Copy link
Owner

guillaumebriday commented May 15, 2018

I don't think it will fix the issue because by running this command you let mysql started, which is the problem here. The migration command run before mysql is ready :/

@tompenzer
Copy link
Contributor

tompenzer commented May 15, 2018

Yeah, doing the front-end build before the migration/seeds seems to have resolved it for me. Alternatively, connecting to the mysql server on 0.0.0.0:3306 with the root/secret account creds in any SQL client will allow migrations to proceed as expected.

@guillaumebriday
Copy link
Owner

I'll try to implement wait-for-it.sh as soon as possible because it causes issues in production which is far more annoying than in development environnement

@AldoRG
Copy link

AldoRG commented Aug 27, 2018

In the .env.example
DB_HOST=mysql
I just replaced that with my local and I added the port like this

DB_HOST=127.0.0.1
DB_PORT=3306

and it works perfectly.

@guillaumebriday
Copy link
Owner

Hum @AldoRG, how did you try ? Did you stop you containers before updating the DB_HOST ? Thanks

@guillaumebriday
Copy link
Owner

I will try today 👍

@guillaumebriday
Copy link
Owner

it does not work @AldoRG

@ooking
Copy link

ooking commented Oct 31, 2018

When I run $ docker-compose run --rm blog-server php artisan migrate , the first step of the 'Before Starting' section I get the following error message:
Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = laravel-blog and table_name = migrations) at /application/vendor/laravel/framework/src/Illuminate/Database/Connection.php: 664

I'm using Valet.

find mysql.sock path and editing php.ini
pdo_mysql.default_socket=
change to
pdo_mysql.default_socket=/private/tmp/mysql.sock
or
editing database.php
'unix_socket' => '/private/tmp/mysql.sock'

good luck

@hadiset
Copy link

hadiset commented Oct 4, 2019

I have same problem like this, I am using docker and laradock, this is my solution,
(Be sure to set DB_HOST to mysql in .env)

  1. Start docker
    docker-compose up -d nginx mysql phpmyadmin workspace redis

  2. Then check container id of workspace
    docker container ls

  3. After that command you'll see result then copy container_id of workspace

  4. Then hit this command
    docker exec -it <workspace container_id> bash
    example docker exec -it d5cb46ad1f69 bash

  5. If success, you'll see your terminal move to like root@d5cb46ad1f69:/var/www#

  6. Then go to your laravel project and try to php artisan migrate or other command

Hope this can help!! Thanks!!

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

No branches or pull requests

7 participants