I download from https://github.com/luciddreamz/laravel Laravel for openshift then upload over my repository over github. This code for connect to database not work. The prob
I was having the same problem and everyone was talking about this is related to DNS configuration, which make sense, since your container maybe isn't knowing how to resolve the name of the domain where your database is.
I guess your can configure that at the moment you start your container, but I think it's better to config this once and for all.
I'm using Windows 10 and in this case docker's gui give us some facilities.
Just right click on docker's icon in the tray bar and select "Settings" item.
Then, on the Docker's window, select the "Network" section and change the DNS option from "Automatic" to "Fixed" and hit "Apply". Docker will restart itself after that. I putted the Google's DNS (8.8.8.8) and it worked fine to me.
Hope it helps.
If you are on production server and the .env file doesn't work at all, go to /bootstrap/cache/config.php and on the line 230 more or less you will find the database data that is beeing cached from the .env file.
'mysql' =>
array (
'driver' => 'mysql',
'host' => '127.0.0.1',
'port' => '3306',
'database' => 'yorDBname',
'username' => 'YOURUSERNAME',
'password' => 'yourpass',
'unix_socket' => '',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
),
In my case, it had absolute nothing to do with network issues.
I had been using my local laravel testing environment using laradock. Because laradock runs the mysql server in a different container, you have to set your mysql host in the .env file to the name of the docker mysql container, which by default is mysql.
When I switched back to using homestead, it was trying to connect to a host named mysql, when in fact is should be looking on localhost.
What a DUH moment!
If you are using Shopware with docker then you need to first run ./psh.phar ssh
then any bin/console
command will work
In my case, everything was set up correctly, but my Docker
infrastructure needed more RAM. I'm using Docker for Mac, where default RAM was around 1 GB, and as MySQL uses around 1.5Gb of RAM ( and probably was crashing ??? ), changing the Docker RAM utilization level to 3-4 Gb solved the issue.
It looks like you did not add a MySQL database to your application, OR you added it after you installed laravel. In that case, you need to stop & start (not restart) your application so that it will pick up your environment variables. (rhc app stop , rhc app start ). If you did not add a database yet, you will need to add one of the mysql cartridges, and then stop & start your application using the previously shown commands.