• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Change the MySQL Password

    Scheduled Pinned Locked Moved Solved
    FOG Problems
    5
    10
    4.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • sudburrS
      sudburr
      last edited by sudburr

      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.

      [ Standing in between extinction in the cold and explosive radiating growth ]

      Wayne WorkmanW A 2 Replies Last reply Reply Quote 2
      • Wayne WorkmanW
        Wayne Workman @sudburr
        last edited by

        @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.

        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
        Daily Clean Installation Results:
        https://fogtesting.fogproject.us/
        FOG Reporting:
        https://fog-external-reporting-results.fogproject.us/

        1 Reply Last reply Reply Quote 0
        • D
          dholtz-docbox
          last edited by

          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

          1 Reply Last reply Reply Quote 1
          • sudburrS
            sudburr
            last edited by sudburr

            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
            

            [ Standing in between extinction in the cold and explosive radiating growth ]

            Wayne WorkmanW Tom ElliottT 2 Replies Last reply Reply Quote 1
            • Wayne WorkmanW
              Wayne Workman @sudburr
              last edited by

              @sudburr would it be easier to write a php script to do it?

              Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
              Daily Clean Installation Results:
              https://fogtesting.fogproject.us/
              FOG Reporting:
              https://fog-external-reporting-results.fogproject.us/

              1 Reply Last reply Reply Quote 0
              • Tom ElliottT
                Tom Elliott @sudburr
                last edited by Tom Elliott

                @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!@@#$%^&*()\'"');
                

                Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                sudburrS 1 Reply Last reply Reply Quote 1
                • sudburrS
                  sudburr @Tom Elliott
                  last edited by sudburr

                  @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
                  

                  [ Standing in between extinction in the cold and explosive radiating growth ]

                  Wayne WorkmanW 1 Reply Last reply Reply Quote 1
                  • Wayne WorkmanW
                    Wayne Workman @sudburr
                    last edited by

                    @sudburr cam you post the whole thing now?

                    Also, can we solve this?

                    Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
                    Daily Clean Installation Results:
                    https://fogtesting.fogproject.us/
                    FOG Reporting:
                    https://fog-external-reporting-results.fogproject.us/

                    1 Reply Last reply Reply Quote 0
                    • sudburrS
                      sudburr
                      last edited by

                      The entire process is the initial post. It’s been edited and indicated.

                      [ Standing in between extinction in the cold and explosive radiating growth ]

                      1 Reply Last reply Reply Quote 1
                      • A
                        abulhol @sudburr
                        last edited by

                        @sudburr In my FOG installation (1.5.5), the value for DATABASE_PASSWORD in config.class.php is in single quotes, so the sed 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).

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post

                        170

                        Online

                        12.0k

                        Users

                        17.3k

                        Topics

                        155.2k

                        Posts
                        Copyright © 2012-2024 FOG Project