Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't connect to the database #4

Closed
falahatiali opened this issue Jun 27, 2019 · 3 comments
Closed

can't connect to the database #4

falahatiali opened this issue Jun 27, 2019 · 3 comments

Comments

@falahatiali
Copy link

I have a problem in the server when I wanna connect database it says for example
SQLSTATE[HY000] [1045] Access denied for user 'database'@'111.111.112.4'

but my IP has changed and now is 111.111.112.1
How can I fix this problem?

@dimadeush
Copy link
Collaborator

Not related to this environment. You have an example in env files and there you can find all database credentials.

@falahatiali
Copy link
Author

excuse me how I can create a new user except root ? I wanna connect database with another user
I have change files as bellow:

 mysql:
      image: mysql:8.0
      container_name: mysql
      restart: always
      command: --default-authentication-plugin=mysql_native_password
      environment:
        - MYSQL_ROOT_PASSWORD=MYPASSWORD!@root
        - MYSQL_USER=myuser
        - MYSQL_DATABASE=mydatabase
        - MYSQL_PASSWORD=MYPASSWORD!@
      ports:
        - "33061:3306"
      volumes:
        - ./storage/mysql-data:/var/lib/mysql
        - ./docker/dev/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=mydatabase
DB_USERNAME=myuser
DB_PASSWORD=MYPASSWORD!@

@dimadeush
Copy link
Collaborator

dimadeush commented Jul 2, 2019

Pay attention to next row:

  • ./storage/mysql-data:/var/lib/mysql

It means that when starting an image all files in /storage/mysql-data will be mapped into container. If you changed some db environment variables just do next:
1)make stop
2)docker-compose build
3)delete folder /storage/mysql-data
4)make start

Then new "/storage/mysql-data" will be generated and everything will work with your new db credentials.

@dimadeush dimadeush changed the title dont donnect database can't connect to the database Jul 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants