PDA

View Full Version : MySQL root user password



juc1
2012-07-27, 03:28 PM
Hi all

I think that the installation of MySQL on a server usually includes setting the the MySQL root user password. My new Debian 6 VPS comes with MySQL pre-installed so does that mean that the MySQL root user password has already been set? If so where do I find it? I know there are SSH commands for setting and re-setting the MySQL root user password but of course these instructions are different according to whether I am creating a password for the first time or resetting an existing password.

Thanks


91

jeremya
2012-07-27, 03:30 PM
Hi Juc,

This depends on whether or not you've got a control panel such as Plesk or cPanel, I believe both will set the MySQL root password accordingly (Plesk for sure). But on a vanilla VPS the password is not set at all by default.

juc1
2012-07-27, 03:59 PM
Hi Juc,

This depends on whether or not you've got a control panel such as Plesk or cPanel, I believe both will set the MySQL root password accordingly (Plesk for sure). But on a vanilla VPS the password is not set at all by default.
Yes it is Parallels Plesk Panel 10.4.4 - but if the MySQL root password has already been set, where can I find it?

Thanks

jeremya
2012-07-27, 04:29 PM
Plesk apparently renames the root user for mysql to admin and sets the password but you can use Plesk commands to retrieve it :)

# /usr/local/psa/bin/admin --show-password

KB Parallels (http://kb.parallels.com/427)

juc1
2012-07-27, 06:40 PM
Plesk apparently renames the root user for mysql to admin and sets the password but you can use Plesk commands to retrieve it :)

# /usr/local/psa/bin/admin --show-password

KB Parallels (http://kb.parallels.com/427)
yes that works to get the password, thanks, but then if I use

mysql -uUSERNAME -pPASSWORD
=

mysql -uadmin -pmypastedpassword

I get


ERROR 1045 (28000): Access denied for user 'admin'@'localhost' (using password: YES)

Does that make sense?

Thanks

92

suwunk
2012-07-28, 12:18 AM
In Plesk by default mysql root is changed to admin. It's supposed to sync passwords with your admin password, but life is never that simple. Try:

mysql -uadmin -p `cat /etc/psa/.psa.shadow`
linux - Using Plesk to setup MySQL - Super User (http://superuser.com/questions/380516/using-plesk-to-setup-mysql)

juc1
2012-07-28, 06:18 AM
In Plesk by default mysql root is changed to admin. It's supposed to sync passwords with your admin password, but life is never that simple. Try:

mysql -uadmin -p `cat /etc/psa/.psa.shadow`
linux - Using Plesk to setup MySQL - Super User (http://superuser.com/questions/380516/using-plesk-to-setup-mysql)

I have tried two passwords - the one output by this...

# /usr/local/psa/bin/admin --show-password

...and the one that is my plesk login password but neither works and both give


ERROR 1045 (28000): Access denied for user 'admin'@'localhost' (using password: YES)

Any suggestions please?

Thanks
93

suwunk
2012-07-28, 11:46 AM
Please consult customer support before applying this following solution, it may cause Plesk failed to load.

If this following command failed

mysql -uadmin -p `cat /etc/psa/.psa.shadow`

You should try this following solution:
1.Load MySQL with the 'skip-grant-tables' option by adding skip-grant-tables into [mysqld] section of the /etc/my.cnf file
2.Restart MySQL with the command line below:

# /etc/init.d/mysqld restart
3.Repair password with the command line below:

# /usr/bin/mysql -D mysql -e"update user set password=PASSWORD('`cat /etc/psa/.psa.shadow`') where User='admin';"
4.Remove skip-grant-tables option from /etc/my.cnf
5.Restart MySQL.

If the solution above still not working, I recommend that you contact Customer Support.

jeremya
2012-07-30, 09:31 AM
Hi Juc,

Sometimes if there are special characters in passwords, pasting into the command line login command isn't the best approach. I've found more luck by typing "mysql -u username -p". When you do this, it will prompt you for the password. You can then past or type it in manually there and you shouldn't have character problems. :)

jeremya
2012-07-30, 09:33 AM
Also, unless you want to toy with fire and break Plesk' connection to the database, i would be very careful with the previous recommendations by Suwunk.