i'm trying to use the mysql service following instructions, but my rails tests fails because they can't connect:
#<Mysql2::Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)> Couldn't create database for {"adapter"=>"mysql2", "database"=>"pipelines", "username"=>"test_user", "password"=>"test_user_password", "host"=>"localhost", "port"=>3306}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"}
this is the relevant pipeline configuration:
services: - mysql definitions: services: mysql: image: mysql environment: MYSQL_DATABASE: pipelines MYSQL_ROOT_PASSWORD: my-secret-pw MYSQL_USER: test_user MYSQL_PASSWORD: test_user_password
and this is the database.yml:
test: adapter: mysql2 database: pipelines username: test_user password: test_user_password host: localhost port: 3306
from the pipeline log the mysql instance seems to run OK, so i'm probably doing something wrong, any idea?
Thanks
Francesco
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
This error message indicates that the Ruby MySQL client is trying to connect via a local, file-based "Unix socket", which won't work in Bitbucket Pipelines. The MySQL server is running in a separate container, so the client needs to use a TCP/IP connection for it to work.
I hit the same problem when using the command-line 'mysql' client in Pipelines, which connects via Unix sockets instead of via TCP if the hostname is 'localhost'. I'm guessing that the Ruby guys copied this logic into their client.
It should work if you change 'localhost' to '127.0.0.1' in your database.yml.
I'm having the same issue although I think you should use the name of the service 'mysql' as the host of the mysql database.
But i'd set the DB_HOST environment variable on the project's pipelines settings and it's not working and my project gets this value to set the host to connect to the database.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.