Add to Favourites Add to Favourites    Print this Article Print this Article

How to re-install MySQL

Before doing anything

We recommend you make full DA backups for easy restore, and CustomBuild mysql backups, just in case.

New Method

CustomBuild 2.0 rev 2914 has the ability to very easily start with a fresh MySQL/MariaDB install of any version.
It will check to see if /var/lib/mysql exists, and if not will do a fresh install of whatever is setup in the options.conf, AND will setup your root/da_admin accounts for you.
  1. Wipe your old data. Of course this assumes you have nothing to lose, or you've made full .sql backups which you plan on restoring manually later on.

    perl -pi -e 's/mysqld=ON/mysqld=OFF/' /usr/local/directadmin/data/admin/services.status
    service mysqld stop
    mv /var/lib/mysql /var/lib/mysql.old

  2. Install the new desired version, say mariadb 10.4 or mysql 5.7, for example.

    except you may want to use "mysql_backup no" since mysqld isn't running.
  3. Rebuild the RoundCube user+db:

    ./build rouncdube

  4. Restore your .sql data, if you had any (avoid touching mysql.*, unless you know what you're doing. Create Users through DA if you're not confident)

Old Method

1) If MySQL needs to be re-installed, or wasn't installed the first time for some reason, you can re-install it with this guide.  It will remove all old databases, so if you have data, make sure you back it up.

cd /usr/local/directadmin/scripts
./ rootpass da_admin daadminpass

where you'd change the passwords to any value that you'd like.
The installer uses the mysql= value for the rootpass, and the adminpass= for the adminpass, both from the setup.txt (same directory).

It may ask you:

It seems as though mysql has already been installed.
The directory /var/lib/mysql has been found.  For the best results, its recommended that this be deleted.
All database data will be lost if you delete it

Do you want to delete it? (y is recommended)? (y,n) :

where you'd want to answer "y" to get a clean start.
If you select "n", then the installer will fail unless the active database allows logins without any passwords. (just answer: y)

2) If you need to use RoundCube, then re-install that too:

cd /usr/local/directadmin/custombuild
./build roundcube

Install MariaDB instead

If the previous install defaults to MySQL and you want to wipe it for a specific version of MariaDB, you'd need to delete the MySQL*.rpm files, from and replace them with the MariaDB rpms before running the, above.  You'll also need to remove the MySQL* rpms from the system after you're done creating the backups.

Adjust these values to make copy/paste quicker:
Major version:
Was this answer helpful?

Also Read