Made a typo and forgot to close quotes while entering new MySQL root password
Solution 1:
Then just reset your MySQL password. This is how I do it in Ubuntu 12.04. Should work similarly in other setups. It’s considered an insecure way of reseting a MySQL password since you do have to launch MySQL in an open/non-credential based mode to do this. But if you do it & then restart MySQL normally, you should be fine.
First, I stop the MySQL service:
sudo service mysql stop
Then I restart it with the --skip-grant-tables
flag:
sudo mysqld --skip-grant-tables &
Now you can login without a password like so:
mysql -u root mysql
And then I run the following query to reset the password. Note you should change the value of YOURNEWPASSWORD
to whatever password you actually want to use:
UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE user='root'; FLUSH PRIVILEGES; exit;
Now that that is done, exit out of MySQL and restart the daemon like so:
sudo service mysql restart
If somehow that doesn’t work, use a killall
to kill all instances of mysqld
:
killall mysqld
And then start the MySQL service again as you normally would:
sudo service mysql start
The new password should be set & you’re good to go.
Solution 2:
Shot in the dark here, but it looks like your password has an embedded newline character now. Try adding \n
to the end of your password string and see if it works, or otherwise inserting the newline/linefeed control character at the end of your password (depends on terminal.)
It also just occurred to me. Can you just repeat the same thing again? e.g.
mysqladmin -u root -p 'password RET
>' whatever-you-want-to-do RET
Obviously a little cumbersome. Don't have an install to test on, or I'd have done so, but worth a shot.
Note: I feel like this has happened to me before.
Solution 3:
If you know *exactly what you typed then you can log in with that value - but you need to specify it on the command line rather than via an ini file or the password pro,pt (where newline is interpreted as the end of the input). For example:
mysqladmin -u root -p"somepassword\n\n\n" password 'newpassword'
If you can't recreate the value you typed in previously then you'll need to go down the different ini file route.