Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Can't connect to mariaDB #194

Open
richardpatsch opened this issue Jan 13, 2016 · 18 comments
Open

Can't connect to mariaDB #194

richardpatsch opened this issue Jan 13, 2016 · 18 comments

Comments

@richardpatsch
Copy link

I get the following error:
SQLSTATE[HY000] [1045] Access denied for user 'user'@'172.17.0.3' (using password: YES)
And when I change the variables:

  • DB_PORT_3306_TCP_ADDR=myIp
  • DB_PORT_3306_TCP_PORT=myPort

within the .env file according to the IP+Port I need, there is still the same error.

@schmunk42
Copy link
Member

Some questions from my side :)

Are you running phundament inside Docker?
Which database do you want to use, also Docker?
Do you have the user user?
Can you set your user here?

DB_ENV_MYSQL_USER=dev
DB_ENV_MYSQL_PASSWORD=dev123

Can you run docker-compose run php yii db/create?
Like so:

Kraftbuch:app tobias$ docker-compose run php yii db/create
Creating app_mariadb_1
Checking database connection on DSN 'mysql:host=172.17.0.2;port=3306' with user 'admin'......... [OK]
Creating database 'dev-phundament-4' and granting permissions to user 'dev' on DSN 'mysql:host=172.17.0.2;port=3306' with user 'admin'. [OK]
Kraftbuch:app tobias$ 

@richardpatsch
Copy link
Author

Thx for your response. Yes, I run phunament inside Docker and I use mysql.
my DB_ENV_MYSQL_USER is actually dev, I've just copied the varName and wrote a random userName, but in my case its "dev" as well.
Your command returns:
Interactive mode is not yet supported on Windows. Please pass the -d flag
when using 'docker-compose run'.
Thx in advance.

@schmunk42
Copy link
Member

Which MySQL image do you use? Could you post your docker-compose.yml? Some images don't support easy user setup.

Are you running docker-compose directly from Windows PowerShell(?) or cmd.exe? Which windows version.

I'd definitely like to support the dockerized setup on Windows, but I have no test-setup ... yet.

@richardpatsch
Copy link
Author

I execute docker-compose within the "Docker Quickstart Terminal".
My docker-compose.yml contains:

# Phundament 4 - Application stack

php:
  build: .
  links:
    - 'mariadb'


nginx:
  image: phundament/nginx-one:1.9
  links:
    - 'php:PHPFPM'

mariadb:
  image: 'tutum/mariadb:10.1'
  environment:
    MARIADB_PASS: secretadmin

@schmunk42
Copy link
Member

Use

php:
  build: .
  links:
    - 'mariadb:DB'

This will prefix ENV variables from the database container with DB_ - Phundament expects this in its config.

Note that links will go away in a future version of Docker.

@richardpatsch
Copy link
Author

Still the same outcome, except that i get another IP-address in my error message (172.17.0.3 instead of 172.17.0.1)

@schmunk42
Copy link
Member

Be aware of data loss in your containers!
But, ... did you docker-compose kill && docker-compose rm -fv?

Could you show the output of docker-compose version and docker info.

@richardpatsch
Copy link
Author

Version:

docker-compose version 1.5.2, build e5cf49d
docker-py version: 1.5.0
CPython version: 2.7.10
OpenSSL version: OpenSSL 1.0.2a 19 Mar 2015

Info:

Containers: 0
Images: 81
Server Version: 1.9.1
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 81
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.1.13-boot2docker
Operating System: Boot2Docker 1.9.1 (TCL 6.4.1); master : cef800b - Fri Nov 20 19:33:59 UTC 2015
CPUs: 1
Total Memory: 996.2 MiB
Name: default
ID: DXXM:Q26V:OIZP:OKRB:25C3:4HIH:VUSY:MNEM:WT5E:JWW6:BTEW:R6CM
Debug mode (server): true
 File Descriptors: 15
 Goroutines: 33
 System Time: 2016-01-18T19:12:11.130391787Z
 EventsListeners: 1
 Init SHA1: 
 Init Path: /usr/local/bin/docker
 Docker Root Dir: /mnt/sda1/var/lib/docker
Labels:
 provider=virtualbox

I tried docker-compose kill && docker-compose rm -fvnow and I when i build/up it again, it's still the same.

@schmunk42
Copy link
Member

Hmmm, I am a bit clueless at the moment.
I'll try to get my hands on a Windows system to debug this. What's your Windows version?

... and does it also don't work with a fresh clone?

@schmunk42
Copy link
Member

CC @disco-tex77 @marc7000 @eluhr @Quexer69 If you could test this on Windows, this would be great.

@philippfrenzel
Copy link
Contributor

Hi, have the same issue:

Database Exception – yii\db\Exception

SQLSTATE[HY000] [1045] Access denied for user 'dev'@'172.17.0.5' (using password: YES)

Caused by: PDOException

SQLSTATE[HY000] [1045] Access denied for user 'dev'@'172.17.0.5' (using password: YES)

in /app/vendor/yiisoft/yii2/db/Connection.php at line 579

@schmunk42
Copy link
Member

@philippfrenzel Could you double check which command is running in the container?
It looks like the startup hasn't completed properly.
Which Docker base-image are you using?

Workaround: make bash
In the container ... either try to run sh src/setup.sh or yii db/create

@philippfrenzel
Copy link
Contributor

image

@schmunk42
Copy link
Member

You may need to update dmstr/yii2-db and add the command, like so

'db' => 'dmstr\console\controllers\MysqlController',

@philippfrenzel
Copy link
Contributor

didn't had that extension in composer at all? Isn't it added by the dmst meta package?

@schmunk42
Copy link
Member

It is, but maybe your version is too old in your app :) Which meta-package version do you have?

@philippfrenzel
Copy link
Contributor

i had to fix tls like this:

first make sure that the virtual machine is running

docker-machine start default

regenerate TLS connection certs

docker-machine regenerate-certs default

finally, set env

eval "$(docker-machine env default)"

@philippfrenzel
Copy link
Contributor

And it's ~2.0.0 ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants