Unknown MySQL host when attaching microservice

I’m currently trying to run Dusk tests on my Laravel project by following the guide on the website, but have come across an issue connecting to the MySQL server.

I attached a MySQL microservice to my PHPUnit action and added apt-get install mysql-client -y at the beginning of the setup script, but when I try to connect to it using mysql --host=mysql --user=root --password=qwerty in the action, it says that the host mysql does not exist.

I’m not really sure what to do from here.

For reference, this is the setup script:

apt-get update && apt-get install -y openssl zlib1g-dev mysql-client
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
docker-php-ext-install zip
apt-get update && apt-get install git -y
docker-php-ext-install pdo mbstring
echo "CREATE DATABASE myproject" | mysql --host=mysql --user=root --password=qwerty

And this is the actual action:

composer install
cp .env.testing .env
HOST_NAME=$(hostname -I | tr -d ' ')
sed -i "s/localhost/$HOST_NAME/g" .env
php artisan migrate
php artisan serve --port 8080 --host $HOST_NAME &
script -c "php artisan dusk" -eq

It of course fails when I try to create the database in the setup portion :slight_smile:

@DoctorBlue, are you on the cloud version or the standalone one?

I’m using Buddy GO

I understand that you put the following in Setup Commands:

echo “CREATE DATABASE myproject” | mysql --host=mysql --user=root --password=qwerty

is that right?

The microservice is not available there. That’s why you cannot connect and create the database. Microservices are available at executing (Run Commands)