mike-works / sql-fundamentals

Mike North's SQL Fundamentals and Professional SQL Courses
https://frontendmasters.com/courses/sql-fundamentals/
BSD 3-Clause "New" or "Revised" License
169 stars 108 forks source link

mysql setup script does not use login file #73

Open AkshayBarad opened 6 years ago

AkshayBarad commented 6 years ago

Hello,

When running the setup script mysql.sh via npm run db:setup:mysql, the mysql and mysqladmin commands do not make use of the login config file created in the setup process. We saw the following output:

- Removing any existing northwind database (you may need to provide a password)
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'akshay'@'localhost' (using password: NO)'
 - Removing any existing northwind_user user
ERROR 1045 (28000): Access denied for user 'akshay'@'localhost' (using password: NO)
 - Creating northwind_user
ERROR 1045 (28000): Access denied for user 'akshay'@'localhost' (using password: NO)
 - Creating northwind database
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'akshay'@'localhost' (using password: NO)'
 - Granting all northwind database permissions to northwind_user
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
 - Setting up schema from ./sql/northwind.mysql.sql
ERROR 1045 (28000): Access denied for user 'akshay'@'localhost' (using password: NO)
 - Importing data from ./sql/northwind_data.sql (this may take a while)
ERROR 1045 (28000): Access denied for user 'akshay'@'localhost' (using password: NO)

We resolved the issue by adding aliases in the mysql.sh file like so:

alias mysqladmin='mysqladmin --login-path=local'
alias mysql='mysql --login-path=local'

I am unsure if this is relevant to all operating systems and all versions of mysql.

I intend to make a PR but would like to wait until I finish the course so that I can ensure that my PR includes fixes to all instances of this specific issue.

Akshay Barad\ BitCraft

mike-north commented 6 years ago

This is a permissions issue on your local machine. The easiest way to take the course on a Mac is using https://postgresapp.com

AkshayBarad commented 6 years ago

Thank you @mike-north, will switch to postgres if there's further trouble. We wanted to familiarise ourselves specifically with mysql because that's what we plan on using for an upcoming project.

Would you be open to accepting the PR I mentioned? My colleague who is following the course from Ubuntu 18.04 with mysql v5.x also faced the issue and setting the aliases helped him as well. I don't see any negative side effects of setting the aliases in conditions when everything works out of the box.

PS: Our entire team has greatly enjoyed and benefited from your courses on FEM. Thank you for being awesome!