Laravel CI/CD in Gitlab, Docker set my IP MySQL
Laravel CI/CD in Gitlab, Docker set my IP MySQL
I followed this Gitlab tutorial to test and deploy Laravel applications with GitLab CI/CD and Envoy.
All works well, but when I run a pipeline it shows this error:
PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'user'@'172.17.0.4' (using password: YES)")
My IP server is 172.0.0.1 but the pipeline set the IP by 172.17.0.4.
How can I set the IP to make work it?
The .env file has the correct password and variables. ` DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=blog DB_USERNAME=user DB_PASSWORD=mypass`
– albertcito
May 26 at 2:59
Your mysql is running inside a docker container right ? If in that case, i think that connect
DB_HOST=127.0.0.1 this way is problem...– Truong Dang
May 26 at 3:02
DB_HOST=127.0.0.1
Please show your
gitlab-ci.yml file– Truong Dang
May 26 at 3:05
gitlab-ci.yml
gitlab-ci.yml: variables: MYSQL_DATABASE: blog MYSQL_ROOT_PASSWORD: V4ld1v1@Ch1l3-2018 DB_HOST: mysql DB_USERNAME: laravel The file is: gitlab.com/albertcito/blog/blob/master/.gitlab-ci.yml– albertcito
May 26 at 3:10
gitlab-ci.yml
1 Answer
1
Finally, it works. I added only this values to the yml file:
yml
variables:
MYSQL_DATABASE: mydatabase
MYSQL_ROOT_PASSWORD: 123456
Obviously the same values to the .env file.
.env
(I also uninstalled and re-installed MySQL, but I don't know if that helped to solve it)
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Show me your connect DB in .env file....
– Truong Dang
May 26 at 2:48