Change the MySQL Password
-
I want to explicitly document changing the password for root for MySQL without needing to re-run the installer as the Wiki suggests.
mysql_secure_installation Enter current password for root: <enter> Set root password? y New password: <new password> Remove anonymous users? y Disallow root login remotely? y Remove test database and access to it? y Reload privilege tables now? y
Then we need to change everywhere FOG references the old password without rerunning the installer.
sed -i.bak "s|snmysqlpass='<oldpassword>'|snmysqlpass='<newpassword>'|g" /opt/fog/.fogsettings sed -i.bak "s|DATABASE_PASSWORD', \"<oldpassword>\"|DATABASE_PASSWORD', \"<newpassword>\"|g" /var/www/html/fog/lib/fog/config.class.php reboot
I’m working on that second sed command’s escape sequence just now. EDIT - completed
Is there anywhere else that needs to be changed? The purpose of this is to avoid re-running the installer just for the sake of a changed MySQL password.
-
@sudburr I think those two text spots are it. Nodes do not use the root pass so no changes there.
Of course, you must issue a MYSQL command to change the password. That’s in the Troubleshoot MYSQL article for quick reference.
-
Thought I might get to answer something on here for once! What Wayne said though is all I had to say
Don’t forget the MYSql call was going to be my one major point to not forget.
-Dustin
-
Changing the MySQL root password is contained in the command:
mysql_secure_installation
I’m still trying to figure out how to escape the replacement strings, since it contains both single quotes ( ’ ) and double quotes ( " ).
DATABASE_PASSWORD', "<oldnewpassword>"
sed -i.bak 's|DATABASE_PASSWORD', "<oldpassword>"|DATABASE_PASSWORD', "<newpassword>")|g' /var/www/html/fog/lib/fog/config.class.php
-
@sudburr would it be easier to write a php script to do it?
-
@sudburr You could try:
escapeshellarg($yourpassword);
Then when you call it you would simply use single quotes where needed.
For example:
<?php $somepass = escapeshellarg('"\'helloworld!@@#$%^&*()\'"');
-
@Tom-Elliott But that’s two steps; I’m aiming for a single step, direct solution.
And I have it now
sed -i.bak "s|DATABASE_PASSWORD', \"<oldpassword>\"|DATABASE_PASSWORD', \"<newpassword>\"|g" /var/www/html/fog/lib/fog/config.class.php
-
@sudburr cam you post the whole thing now?
Also, can we solve this?
-
The entire process is the initial post. It’s been edited and indicated.
-
@sudburr In my FOG installation (1.5.5), the value for
DATABASE_PASSWORD
inconfig.class.php
is in single quotes, so thesed
statement for needs to be:sed -i.bak 's|DATABASE_PASSWORD', '<oldpassword>'|DATABASE_PASSWORD', '<newpassword>')|g' /var/www/html/fog/lib/fog/config.class.php
I would also like to note that the values in
.fogsettings
are only initial values for during installation. So it does not matter if you patch the password there really (not 100% sure though).