phundament / app

Dockerized Yii2 web application base
http://phundament.com
Other
310 stars 129 forks source link

Can't connect to mariaDB #194

Open richardpatsch opened 8 years ago

richardpatsch commented 8 years ago

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:

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

schmunk42 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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

philippfrenzel commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

image

schmunk42 commented 8 years ago

You may need to update dmstr/yii2-db and add the command, like so https://github.com/phundament/app/blob/cd8603268186844bdd788d509c3266e5b8579efd/src/config/main.php#L200

philippfrenzel commented 8 years ago

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

schmunk42 commented 8 years ago

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

philippfrenzel commented 8 years ago

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 commented 8 years ago

And it's ~2.0.0 ;)