vmware-marketplacewordpress-multisite

Modify the MySQL administrator password

NOTE: We are in the process of modifying the configuration for many Bitnami stacks. On account of these changes, the file paths and commands stated in this guide may change depending on whether your Bitnami stack uses MySQL or MariaDB. To identify which database server is used in your stack, run the command below:

 $ test -d /opt/bitnami/mariadb && echo "MariaDB" || echo "MySQL"

The output of the command indicates which database server (MySQL or MariaDB) is used by the installation, and will allow you to identify which guides to follow in our documentation for common database-related operations.

Change the MySQL root password

NOTE: When setting a new password, avoid the use of special characters or quotes, as this can sometimes cause issues when accessing the database through shell scripts.

You can modify the MySQL password using the following command at the shell prompt. Replace the NEW_PASSWORD placeholder with the actual password you wish to set.

$ /opt/bitnami/mysql/bin/mysqladmin -p -u root password NEW_PASSWORD

Reset the MySQL root password

If you don’t remember your MySQL root password, you can follow the steps below to reset it to a new value:

  • Create a file in /tmp/mysql-init with the content shown below (replace NEW_PASSWORD with the password you wish to use).

    If your stack ships MySQL v8.x, use this content:

      ALTER USER 'root'@'127.0.0.1' IDENTIFIED BY 'NEW_PASSWORD';
      ALTER USER 'root'@'localhost' IDENTIFIED BY 'NEW_PASSWORD';
    

    If your stack ships MySQL v5.7.x, use this content:

      ALTER USER 'root'@'localhost' IDENTIFIED BY 'NEW_PASSWORD';
    

    If your stack ships MySQL v5.6.x or earlier, use this content:

      UPDATE mysql.user SET Password=PASSWORD('NEW_PASSWORD') WHERE User='root';
      FLUSH PRIVILEGES;
    

    TIP: Check the MySQL version with the command /opt/bitnami/mysql/bin/mysqladmin --version or /opt/bitnami/mysql/bin/mysqld --version

  • Stop the MySQL server:

      $ sudo /opt/bitnami/ctlscript.sh stop mysql
    
  • Start MySQL with the following command:

    If your stack ships MySQL v8.x, use this command:

      $ sudo /opt/bitnami/mysql/bin/mysqld_safe --pid-file=/opt/bitnami/mysql/data/mysqld.pid --datadir=/opt/bitnami/mysql/data --init-file=/tmp/mysql-init --lower_case_table_names=1 2> /dev/null &
    

    If your stack ships an older version of MySQL, use this command:

      $ sudo /opt/bitnami/mysql/bin/mysqld_safe --pid-file=/opt/bitnami/mysql/data/mysqld.pid --datadir=/opt/bitnami/mysql/data --init-file=/tmp/mysql-init 2> /dev/null &
    
  • Restart the MySQL server:

      $ sudo /opt/bitnami/ctlscript.sh restart mysql
    
  • Remove the script:

      $ rm /tmp/mysql-init
    
Last modification December 21, 2022