In the later versions of the Nextcloud VM we now store the password in /root.my.cnf instead (since 11.0.3), and removes the old mysql_password file that we used in previous versions. This have resulted in that some upgrades fails due that the password is missing (it should work normally but it fails sometimes) and you end up with having to:

  1. Reset the root password
  2. Create /root/.my.cnf with the correct root DB password.
reset the MYSQL root password

The password should be in /var/mysql_password.txt, so before you begin with reseting the root password, please check there first.

$~: sudo cat /var/mysql_password.txt

If that file isn’t found or is empty then continue this guide.

First become root with the first command, then just copy and paste the following commands in to your terminal and press enter.

  1. $~: sudo -i
  2. $~: mkdir -p /var/run/mysqld
  3. $~: chown mysql:mysql /var/run/mysqld
  4. $~: sudo /etc/init.d/mysql stop
  5. $~: sudo mysqld_safe --skip-grant-tables &
    1. Then when paste this and hit [ENTER]
      mysql -uroot
  6. When you are logged in to MySQL then reset your password with these commands:
    You can visit https://lastpass.com/generatepassword.php to generate a secure password.
    Check this out if you are looking for a password manager.

    1. use mysql;
    2. update user set authentication_string=password('YOURSUPERSECRETPASSWORD') where user='root';
    3. flush privileges;
    4. quit
  7. Restart MySQL
    1. $~: sudo /etc/init.d/mysql stop
    2. $~: sudo /etc/init.d/mysql start
  8. Now your password should be reset. You can test it with this command:
    $~: mysql -u root -pYOURSUPERSECRETPASSWORD

    If it works, then you successfully reset the MySQL root password.

Add it to .my.cnf
  1. $~: sudo -i
  2. $~: sudo nano /root/.my.cnf
  3. Add this to the empty file:
    [client]
    password='YOURSUPERSECRETPASSWORD'
  4. Set secure permissions
    1. $~:  cd /root
    2. $~:  chown root:root .my.cnf
    3. $~:  chmod 600 .my.cnf
Test that it works
$~: mysql -u root

Now you should get logged in. If not, something is wrong.

Run the update process again
$~: sudo bash /var/scripts/update.sh