Creating a MySQL installation for local testing

In this article, learn how to install MySQL locally in a virtual machine for your own website testing and development.

This article describes how to create a MySQL installation that you can use for local testing.

🚧

Important

The following procedures assume that you have already created a virtual machine running AlmaLinux on your local computer. For information about how to do this, please see this article.

Installing MySQL

Hosting.com servers actually use MariaDB, an enhanced drop-in replacement for MySQL.

📘

Note

For detailed information about compatibility between MariaDB and MySQL, please visit https://mariadb.com/kb/en/library/mariadb-vs-mysql-compatibility.

To install MariaDB on your virtual machine, follow these steps:

  1. Start the virtual machine, if you haven't already.

  2. Log in to the virtual machine as the root user.

  3. At the command prompt, type the following command to install MariaDB:

    yum install mariadb-server
    
  4. At the Is this ok prompt, type y and then press Enter. The installation process begins.

  5. After installation completes, type the following command to start MariaDB:

    systemctl start mariadb
    
  6. To confirm MariaDB is running, type the following command:

    systemctl status mariadb
    

    You should see Active: active (running) in the output.

  7. To make MariaDB start automatically on system boot, type the following command:

    systemctl enable mariadb
    
  8. To secure the installation, type the following command:

    mysql_secure_installation
    

    This program enables you to set the root MySQL password and other security-related settings.

  9. To make sure the root password was set correctly, type the following command:

    mysql -u root -p
    
  10. Type the root password that you set in step 8, and then press Enter. You should see Welcome to the MariaDB monitor in the output.

👍

Tip

Now that you have installed MariaDB, you are ready to configure it. For information about how to set up MySQL databases, users, and more, please see the Related Articles section below.

Related Articles