freekmurze / freek-dev-comments

2 stars 0 forks source link

1590-how-to-use-a-mysql-database-on-github-actions #12

Open utterances-bot opened 4 years ago

utterances-bot commented 4 years ago

How to use a MySQL database on GitHub Actions - Freek Van der Herten's blog on PHP, Laravel and JavaScript

Freek Van der Herten is a developer and partner at Spatie.

https://freek.dev/1590-how-to-use-a-mysql-database-on-github-actions

chrisan commented 4 years ago

Man I was pounding my head against the wall for a solid hour trying to figure out a connection refused error until I found this post and the DB_PORT env var

Thank you!

freekmurze commented 4 years ago

hope your head is ok :-)

On Tue, 14 Apr 2020 at 19:15, chrisan notifications@github.com wrote:

Man I was pounding my head against the wall for a solid hour trying to figure out a connection refused error until I found this post and the DB_PORT env var

Thank you!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/freekmurze/freek-dev-comments/issues/12#issuecomment-613569338, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADWEDJH6GDDR5QK5ZTJYF3RMSK4DANCNFSM4MH5DAGA .

shamscorner commented 4 years ago

I am having this error when running migrations SQLSTATE[HY000] [1045] Access denied for user 'forge'@'172.18.0.1' (using p
assword: NO) (SQL: select * from information_schema.tables where table_sche
ma = forge and table_name = migrations and table_type = 'BASE TABLE')

Is there anything else I have to do?

fokosun commented 4 years ago

I'm stuck here to. My phpunit.xml.dist is updated to look like the one you shared. I also set MYSQL_ALLOW_EMPTY_PASSWORD: yes to allow for no password. I still get this access denied error.

Is there anything else I have to do? Thank you.

its-leofisher commented 3 years ago

I needed to remove all DB_* entries from my .env.testing file, in my case I was setting a <env name="APP_ENV" value="testing"/> and let the DB entries in the phpunit.xml file be the config settings used.

tomasnorre commented 3 years ago

Thanks a lot for sharing. I have just started with GitHub Actions and looking into speeding up my tests, I saw this regarding the MySQL Service.

My experience though is that my tests is ~2min slower when running MySQL as a Docker service compare to running it as a service directly on the runner.

I have as part of my steps.

 - name: Start database server
   run: sudo /etc/init.d/mysql start

And that is for me faster than the MySQL Docker service.

I was aiming for the MySQL Docker service as I hoped I could have it started as in memory with a tmfps to speed it up.

Doing that when running my tests locally. I haven't found out how to do this on GitHub Actions yet.

Do you have any input on performance, why you went for the MySQL Docker Service way instead of "native" MySQL on the runner?

agnes512 commented 3 years ago

run: sudo /etc/init.d/mysql start gives me 8.0 version MySQL instead of 5.7 though.

Giacomo92 commented 2 years ago

Follow this guide in order to solve the connection errors https://ovirium.com/blog/how-to-make-mysql-work-in-your-github-actions/

It most likely means that a host (ubuntu-20.04) can’t connect to a separate MySQL container that is created using your services:mysql details due to ports issues.

dalefknight commented 2 years ago

Thank you!