mpope9 / nba-sql

:basketball: An application to build an NBA database backed by MySQL, Postgres, or SQLite
Apache License 2.0
177 stars 22 forks source link

MySQL Access denied for user 'nba_sql'@'localhost' #95

Closed mvgary094 closed 1 year ago

mvgary094 commented 1 year ago

I'm getting the error: Access denied for user 'nba_sql'@'localhost' when I try to push data into an existing mysql db. I ran the docker-compose script and then was able to verify the container worked as expected by going into the container and logging into the mysql db using the following command: mysql --host=localhost --user=nba_sql --password=nba_sql nba. I tried using 127.0.0.1 but that gives a cannot connect error.

For context, I found that args.username and password were null so I had to update the code to pass a value.

I was wondering if anyone had run into this issue and had an idea of how to fix it.

Thanks, Mike

mpope9 commented 1 year ago

Hi,

I am not sure what process that you are using, but there is the provided fie: scripts/create_mysql.sh that you can run on mac or linux. I'm able to run that script against the MySQL docker container that I've started with:

docker-compose -f docker/docker-compose-mysql.yml up -d

Does that help at all?

mvgary094 commented 1 year ago

Yea, I should have put in the exact command but that was the docker-compose script I referenced in my question

mvgary094 commented 1 year ago

In this screenshot, I've logged into the mysql docker container. The mysql command I execute is to log into my server image

mvgary094 commented 1 year ago

After running the docker-compose script for mysql that you referenced above, I was able to login to the server and see the nba db. However, I keep getting this error even with the mysql container running

mvgary094 commented 1 year ago

image

mvgary094 commented 1 year ago

image

mvgary094 commented 1 year ago

Just wanted to show the output of the args to see if you saw anything unusual

image

mvgary094 commented 1 year ago

image

mvgary094 commented 1 year ago

Sorry to spam you with screenshots but I just want to be as transparent as possible. The only modification I made to the compose script was the port number(3306 --> 3307). I'm also running this in pycharm venv if that makes a difference

mpope9 commented 1 year ago

Try this:

set DB_PASSWORD=nba_sql
python stats/nba_sql.py --default-mode --database="mysql" --create-schema --username=nba_sql --database_name=nba --database_host=localhost

I've never tried to ran this from the windows cmline, just from the provided application. So what I see missing is the host, username, and password. This doesn't support running the command without using the password as an environment variable and I think the first set DB_PASSWORD=nba_sql accomplishes that. The extra commandline args will set the missing fields.

mvgary094 commented 1 year ago

Alright, I figured out that there was an issue with trying to use a different port number. I think there must be a port setting in peewee that was set by default to 3306. I have removed the container that was listening to 3306 and now I'm getting data flowing in. Thanks a ton for your help and being so quick to respond!

mpope9 commented 1 year ago

Glad it worked out!