• Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
  • 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.
  • S
    sudburr
    last edited by sudburr Oct 5, 2016, 7:49 AM Oct 4, 2016, 8:37 PM

    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 ]

    W A 2 Replies Last reply Oct 4, 2016, 8:44 PM Reply Quote 2
    • W
      Wayne Workman @sudburr
      last edited by Oct 4, 2016, 8:44 PM

      @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 Oct 4, 2016, 8:47 PM

        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
        • S
          sudburr
          last edited by sudburr Oct 4, 2016, 3:08 PM Oct 4, 2016, 9:02 PM

          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 ]

          W T 2 Replies Last reply Oct 4, 2016, 9:23 PM Reply Quote 1
          • W
            Wayne Workman @sudburr
            last edited by Oct 4, 2016, 9:23 PM

            @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
            • T
              Tom Elliott @sudburr
              last edited by Tom Elliott Oct 4, 2016, 3:50 PM Oct 4, 2016, 9:50 PM

              @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

              S 1 Reply Last reply Oct 5, 2016, 1:46 PM Reply Quote 1
              • S
                sudburr @Tom Elliott
                last edited by sudburr Oct 5, 2016, 7:49 AM Oct 5, 2016, 1:46 PM

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

                W 1 Reply Last reply Oct 5, 2016, 9:03 PM Reply Quote 1
                • W
                  Wayne Workman @sudburr
                  last edited by Oct 5, 2016, 9:03 PM

                  @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
                  • S
                    sudburr
                    last edited by Oct 6, 2016, 3:15 PM

                    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 Dec 6, 2019, 8:56 AM

                      @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

                      262

                      Online

                      12.0k

                      Users

                      17.3k

                      Topics

                      155.2k

                      Posts
                      Copyright © 2012-2024 FOG Project