Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

PHP artisan command fails when executing in pipelines


I'm working on a Laravel project and when the pipelines are executed, it fails when executing the migration: php artisan migrate.

php artisan migrateIn Connection.php line 671: SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from inform ation_schema.tables where table_schema = bitbucket and table_name = migrati ons and table_type = 'BASE TABLE') In Connector.php line 70: SQLSTATE[HY000] [2002] No such file or directory

Here is part of my script:

image: lbausch/laravel-ci
definitions: steps:
step: &build-image
name: Build image
#Copy Environment File
cp .env.pipelines .env
#Install Composer
curl -sS | php -- --install-dir=/usr/local/bin --filename=composer
composer install
# Migrate database
php artisan key:generate
php artisan migrate
chmod -R 0755 bootstrap/cache
#Add MySql Database
image: mysql:5.7
MYSQL_DATABASE: 'bitbucket'
MYSQL_PASSWORD: 'bitbucket'
MYSQL_USER: 'bitbucket'


I confirmed that in this docker image the drivers are enabled:

PDOPDO support => enabledPDO drivers => mysql, sqlitepdo_mysqlPDO Driver for MySQL => enabledClient API version => mysqlnd 7.4.4

Does anyone know to solve this error? 

1 answer

The Mysql error message

SQLSTATE[HY000] [2002] No such file or directory

shows that artisan via php pdo connects to the mysql server via a socket file. this is not available in the pipeline and it therefore fails.

instead the mysql service is reachable via the ip address change the artisan/laravel configuration from "localhost" to "" and then it should work.

it is a special thing that mysql connects via a socket if "localhost" is used.

maybe setting the DB_HOST environment variable to does it already.

@ktomk yes, I already have this configuration in my .env file but it's not working




hmm, from the error message I was quite sure this would be it.

is the service properly starting (I would first of all assume that, but perhaps double check the mysql service output in the logs).

mysql takes some seconds to start, if it's not yet available, then there would be also connection problems (however I normally see these not with "file not found" but something along the lines like connection refused or could not connect, however not using PDO.)

maybe the .env is not effective? or it is effective but some other variables from the environment render it useless? (e.g. DB_HOST is set to "localhost" in a (pipeline) environment variable which then overrides the value in .env).

is more information available with verbose output of the artisan command? (I don't have it at hand, often this is a -v / -vvv / --verbose switch - just reading that with artisan verbosity might only affect error cases)

@ktomk The connection is working, I tested by connecting to the database and making a query:

+ mysql -h -u bitbucket -pbitbucket -e 'show databases;

But when executing the artisan command doesn't work. Also I tested by explicitly putting the environment variables:

export DB_DATABASE=bitbucket DB_USERNAME=bitbucket DB_PASSWORD=bitbucket

Something that it's weird is that in the mysql logs is that it doesn't display a hostname but an asterik:

hostname (bind-address): '*'; port: 3306

2020-06-28T23:37:05.443951Z 0 [Note] Server hostname (bind-address): '*'; port: 3306 2020-06-28T23:37:05.444019Z 0 [Note] IPv6 is available.2020-06-28T23:37:05.444615Z 0 [Note] - '::' resolves to '::';2020-06-28T23:37:05.444661Z 0 [Note] Server socket created on IP: '::'.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

423 views 13 14
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you