I am very new to programming and have been tasked to run an app through a docker container using mySql server. I have been unable to connect to the server (although the server is showing running in docker desktop). The error message I keep receiving via the terminal after going through the procedure is:
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlState: '28000',
sqlMessage: "Access denied for user ''@'localhost' (using password: YES)"
I am using MacOS Big Sur, with Docker Desktop Version 4.7.1, mySql Server version: 8.0.28 Homebrew, npm and nodejs.
Procedure being run in the terminal after cloning remote repo files into my local environment:
docker pull mysql/mysql-server
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=<123456> -e MYSQL_DATABASE=flash_card mysql:5.7
name=$(docker inspect --format="{{.Id}}" mysql)
docker exec -i $name mysql --user=root --password=<123456> "flash_card" < dbschema.sql
npm install
node index.js # **Error occurs here**
The Docker Desktop shows the mySql server is running. When attempting to open the connection through the browser, the following error occurs:
This page isn’t working. localhost sent an invalid response.
ERR_INVALID_HTTP_RESPONSE
I tried mysql -u root -p and changing my password and flushing privileges. Restarting the SQL server. Still no luck. I do not have SQL workbench installed and would like a solution that can be done through the docker container mySQL image via the command terminal. If there is a solution through SQL workbench that would be appreciated as well.