0

When I'm trying

mysql -u mlimon -p

Then input the password it successfully login to the MySQL but when I'm trying something like this

mysql -umlimon -pmySqlPassword

Or

mysql -u mlimon -p mySqlPassword

OR

mysql -umlimon -p <<MY_QUERY
USE mysql
SHOW tables
MY_QUERY

It's returning

ERROR 1045 (28000): Access denied for user 'mlimon'@'localhost' (using password: YES)" Or something Error 1044 Access denied

My main intention to run some query in shell script but if I can't login directly to the database it's won't run and when I'm trying to pass the password it's showing access denied. but my question is why it's working when I'm imputing the password in command separately and not working with other way?

NOTE: my password contain a dollar sign, so is this something make the difference here?

Marko Ivkovic
  • 1,262
  • 1
  • 11
  • 14
mlimon
  • 661
  • 8
  • 19
  • Has this user been associated with this database? – Martin Jul 09 '21 at 07:30
  • [This question](https://stackoverflow.com/questions/27415371/how-to-escape-dollar-sign-in-mysql-when-executed-by-command-line) may be of interest re dollar sign – Martin Jul 09 '21 at 07:31
  • Does this answer your question? [Assign an existing user to mysql databases](https://stackoverflow.com/questions/22199557/assign-an-existing-user-to-mysql-databases) – Martin Jul 09 '21 at 07:32
  • Please remove the ```sql-server``` tag as that is different than mysql – Bee_Riii Jul 09 '21 at 07:37
  • @Martin actually mlimon is a root user like everyone has root username. So, i'm trying to create new user and database from shell script here. normall mysql login working fine but when i'm passing password for run -e directly it's showing this error – mlimon Jul 09 '21 at 07:48
  • @Bee_Riii that actually just an example it's not the make the different here – mlimon Jul 09 '21 at 07:49

0 Answers0