Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 111000101/7c0f8b21e8b3366a6eafc33f4c962b64 to your computer and use it in GitHub Desktop.
Save 111000101/7c0f8b21e8b3366a6eafc33f4c962b64 to your computer and use it in GitHub Desktop.
XAMPP - Replace MariaDB with MySQL

XAMPP - Replace MariaDB with MySQL

Since XAMPP 5.5.30 and 5.6.14, XAMPP ships MariaDB instead of MySQL. MariaDB is not 100% compatible with MySQL and can be replaced with the "orginal" MySQL server.

Backup

  • Backup the old database into a sql dump file
  • Stop the MariaDB service
  • Rename the folder: c:\xampp\mysql to c:\xampp\mariadb

Installation

  • Download MySQL Community Server: https://dev.mysql.com/downloads/mysql/
  • Goto: Other Downloads > ZIP Archive 5.7.19 306.2M (mysql-5.7.19-win32.zip) > No thanks, just start my download.
  • Create a new and empty folder: c:\xampp\mysql
  • Extract mysql-5.7.19-win32.zip to: c:\xampp\mysql
  • Create a new and empty folder: c:\xampp\mysql\data
  • Create a new file: c:\xampp\mysql\bin\my.ini and copy this content:
[mysqld]
# set basedir to your installation path
basedir=c:/xampp/mysql
# set datadir to the location of your data directory
datadir=c:/xampp/mysql/data

Initializing the data directory

Initialize a MySQL installation by creating the data directory and populating the tables in the mysql system database.

Open the console (cmd) and enter:

cd c:\xampp\mysql\bin
mysqld --initialize
mysqld --initialize-insecure

The server creates a 'root'@'localhost' and a random password.

Check to make sure that the c:\xampp\mysql\data directory was created. If successful you will find a a [computer name].err file in the data folder with the temporary one time use password for you to login as root for the first time.

Open with Notepad++: c:\xampp\data\[computer name].err

[Note] A temporary password is generated for root@localhost: **************

Copy the password

Start the server

You can use the XAMPP Control Panel (MySQL > Start) to start the MySQL service.

Connect to the server

Open a new console (cmd) window and enter:

cd c:\xampp\mysql\bin
mysql -u root -p

Enter the password you have found in the .err file and press enter.

Now reset the root password to '' (empty).

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '';

Exit the mysql command:

mysql> exit

Restore

Restore the data from the backup file

Finished

Click at the Github β˜… Star :-)

Upgrading from an older version (optional)

Repair all corrupted tables:

mysqlcheck.exe -u root -p --auto-repair --all-databases

Update structure to latest version:

mysql_upgrade.exe -u root -p

Tuning my.ini

You can increase the innodb buffer pool size to gain more performance. The sql-mode setting is only necessary for MySQL versions < 5.7.

[mysqld]
# set basedir to your installation path
basedir=c:/xampp/mysql
# set datadir to the location of your data directory
datadir=c:/xampp/mysql/data

# Default: 134217728 (128 MB)
# New: 1024 MB
innodb_buffer_pool_size = 1024M

# Default since version 5.7
sql-mode = "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
@wallshapel
Copy link

how to do the same on ubuntu?

@TonyStarkze
Copy link

for Linux?

@Pritpal-Stack
Copy link

for Mac

@Jatkingmodern
Copy link

Replace MariaDB with MySQL in XAMPP (Linux)

  1. Backup your MariaDB databases

Open a terminal and dump all your databases:

cd /opt/lampp/bin
./mysqldump -u root -p --all-databases > ~/mariadb_backup.sql

Stop MariaDB:

sudo /opt/lampp/lampp stopmysql

  1. Rename the existing MariaDB folder
    cd /opt/lampp
    sudo mv mysql mariadb

  2. Download MySQL Community Server (Linux tarball)

Go to MySQL Downloads
.
Choose Linux - Generic (glibc2.17) (x86, 64-bit), tar.gz.
Example filename: mysql-8.0.xx-linux-glibc2.17-x86_64.tar.gz

Download & extract:

cd /opt/lampp
sudo mkdir mysql
cd mysql
sudo tar --strip-components=1 -xvf ~/Downloads/mysql-8.0.*.tar.gz

  1. Create a data directory
    cd /opt/lampp/mysql
    sudo mkdir data

  2. Create MySQL config file (my.cnf)

Create /opt/lampp/mysql/my.cnf with:

[mysqld]
basedir=/opt/lampp/mysql
datadir=/opt/lampp/mysql/data
socket=/opt/lampp/var/mysql/mysql.sock
pid-file=/opt/lampp/var/mysql/mysql.pid
port=3306

  1. Initialize the MySQL data directory
    cd /opt/lampp/mysql/bin
    sudo ./mysqld --initialize --user=mysql --datadir=/opt/lampp/mysql/data

If you want without root password on first start:

sudo ./mysqld --initialize-insecure --user=mysql --datadir=/opt/lampp/mysql/data

Check /opt/lampp/mysql/data/hostname.err for the generated root password (if not using --insecure).

  1. Update XAMPP control script

Edit /opt/lampp/lampp and update any MariaDB-related lines to point to /opt/lampp/mysql/bin/mysqld.

Example snippet:

$mysqlstart="$LAMPP_ROOT/mysql/bin/mysqld_safe --defaults-file=$LAMPP_ROOT/mysql/my.cnf --datadir=$LAMPP_ROOT/mysql/data &"

  1. Start MySQL
    sudo /opt/lampp/lampp startmysql

Check:

/opt/lampp/mysql/bin/mysql -u root -p

  1. Restore your backup
    cd /opt/lampp/bin
    ./mysql -u root -p < ~/mariadb_backup.sql

  2. Optional tuning

Inside /opt/lampp/mysql/my.cnf you can tweak:

innodb_buffer_pool_size = 1024M
sql-mode = "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

βœ… Done β€” now your XAMPP on Ubuntu runs MySQL instead of MariaDB.

πŸ‘‰ Do you want me to also write you a Mac (MAMP/XAMPP) version of this guide, like the one you pasted for Windows?

You said:
fo Mac
ChatGPT said:

Perfect πŸ‘ you want the same process but for macOS (XAMPP / MAMP environment).
Here’s how to replace MariaDB with the original MySQL on macOS:

πŸ”„ Replace MariaDB with MySQL in XAMPP (macOS)

  1. Backup your MariaDB databases

Open Terminal and dump everything:

cd /Applications/XAMPP/xamppfiles/bin
./mysqldump -u root -p --all-databases > ~/mariadb_backup.sql

Stop MariaDB:

sudo /Applications/XAMPP/xamppfiles/xampp stopmysql

  1. Rename the MariaDB folder
    cd /Applications/XAMPP/xamppfiles
    sudo mv mysql mariadb

  2. Download MySQL Community Server for macOS

Go to πŸ‘‰ MySQL Community Downloads
.

Select macOS 13 (x86, 64-bit) or macOS 14 ARM (Apple Silicon) depending on your Mac.

Choose Compressed TAR Archive (not DMG installer), e.g.:

mysql-8.0.xx-macos13-x86_64.tar.gz (Intel Mac)

mysql-8.0.xx-macos14-arm64.tar.gz (Apple Silicon)

  1. Install MySQL into XAMPP

Extract into XAMPP’s mysql folder:

cd /Applications/XAMPP/xamppfiles
sudo mkdir mysql
cd mysql
sudo tar --strip-components=1 -xvf ~/Downloads/mysql-8.0.*.tar.gz

  1. Create the data directory
    cd /Applications/XAMPP/xamppfiles/mysql
    sudo mkdir data

  2. Create MySQL config file (my.cnf)

Make /Applications/XAMPP/xamppfiles/mysql/my.cnf with this content:

[mysqld]
basedir=/Applications/XAMPP/xamppfiles/mysql
datadir=/Applications/XAMPP/xamppfiles/mysql/data
socket=/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
pid-file=/Applications/XAMPP/xamppfiles/var/mysql/mysql.pid
port=3306

  1. Initialize MySQL database

Run:

cd /Applications/XAMPP/xamppfiles/mysql/bin
sudo ./mysqld --initialize --user=_mysql --datadir=/Applications/XAMPP/xamppfiles/mysql/data

πŸ‘‰ If you want no password on first start:

sudo ./mysqld --initialize-insecure --user=_mysql --datadir=/Applications/XAMPP/xamppfiles/mysql/data

After success, check:

ls /Applications/XAMPP/xamppfiles/mysql/data

You should see a hostname.err file β€” if not, initialization failed.

  1. Update XAMPP startup script

Edit:

sudo nano /Applications/XAMPP/xamppfiles/xampp

Find the MySQL/MariaDB section and update paths from mariadb to /Applications/XAMPP/xamppfiles/mysql/bin/mysqld_safe.

  1. Start MySQL
    sudo /Applications/XAMPP/xamppfiles/xampp startmysql

Test connection:

/Applications/XAMPP/xamppfiles/mysql/bin/mysql -u root -p

  1. Restore your databases
    cd /Applications/XAMPP/xamppfiles/bin
    ./mysql -u root -p < ~/mariadb_backup.sql

  2. Optional tuning

In /Applications/XAMPP/xamppfiles/mysql/my.cnf you can optimize:

innodb_buffer_pool_size = 1024M
sql-mode = "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

βœ… Done β€” now your macOS XAMPP runs real MySQL instead of MariaDB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment