1

I did a fresh install of laradock for our new project but I cant seem to connect to root@localhost. If I am correct, I don't need to install mysql to my host since Laradock will install it as a service(Please correct me on this).

This is the laradock env file:

### MYSQL #################################################

MYSQL_VERSION=latest
MYSQL_DATABASE=dbname
MYSQL_USER=user
MYSQL_PASSWORD=userpassword
MYSQL_PORT=4306 ############### change port 
MYSQL_ROOT_PASSWORD=rootpassword
MYSQL_ENTRYPOINT_INITDB=./mysql/docker-entrypoint-initdb.d

I also read somewhere that I need to create a createdb.sql inside laradock/mysql:

DROP USER IF EXISTS 'user'@'%' ;
DROP USER IF EXISTS 'root'@'%' ;

CREATE USER 'root' IDENTIFIED BY 'rootpassword';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;

CREATE USER 'user' IDENTIFIED BY 'userpassword';
GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost';
CREATE DATABASE IF NOT EXISTS `dbname` COLLATE 'utf8_general_ci';

FLUSH PRIVILEGES;

I am new to laravel and know a bit of docker but my knowledge is still insufficient. Please shed some light what I did wrong or missing.

Note, at first, I did just added the drop/create root later since it did not work too.

I am trying to access mysql through:

docker-compose exec mysql bash

The error is ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).

Sorry I should have also stated that I cannot access mysql so I cannot delete and create a new one.

Question: If I delete the container/image then docker-compose up -d mysql, would it delete the previous settings that was inside the previous container? Or would it still remain?

rod james
  • 369
  • 3
  • 13
  • Does this answer your question? [MySQL: How to reset or change the MySQL root password?](https://stackoverflow.com/questions/16556497/mysql-how-to-reset-or-change-the-mysql-root-password) – Progman Jun 06 '21 at 14:47
  • Not really. I tried that before and did nt work. Why close the question?? – rod james Jun 06 '21 at 15:42
  • The answer you gave needs to login to the mysql but like I said earlier, I cannot access mysql. Please un close the question. – rod james Jun 06 '21 at 15:45

0 Answers0