Installing MariaDB
Installing MariaDB can vary slightly depending on the operating system you are using. In this article, we'll guide you through the installation process for MariaDB on Linux, Windows, and macOS. Let's get started!
Installing MariaDB on Linux
We'll cover the installation process for the most popular Linux distributions: Ubuntu, Debian, CentOS, and Fedora.
Ubuntu and Debian
-
Update Package Index
Open a terminal and run the following command to update your package index.sudo apt update -
Install MariaDB Server
Install the MariaDB server package using the command below:sudo apt install mariadb-server -
Secure the Installation
After installation, it's important to run a security script that comes with MariaDB. This will help you set up options that enhance your installation's security.sudo mysql_secure_installationYou'll be prompted to set a root password, remove anonymous users, disallow root login remotely, and remove the test database. Go through each prompt and provide your preferred options.
-
Start MariaDB
You can start the MariaDB service with:sudo systemctl start mariadb -
Enable at Boot
To ensure that MariaDB starts automatically at boot, use the command:sudo systemctl enable mariadb -
Verify the Installation
To confirm that MariaDB is installed correctly, connect to the database server:sudo mysql -u root -pIf you entered your password correctly and connected successfully, congratulations! MariaDB is now installed on your Linux machine.
CentOS
-
Install the MariaDB Repository
First, install the EPEL repository before installing MariaDB.sudo yum install epel-release -
Install MariaDB Server
Now, install MariaDB using the following command:sudo yum install mariadb-server -
Start and Enable the Service
Start the MariaDB service and enable it to start on boot:sudo systemctl start mariadb sudo systemctl enable mariadb -
Secure the Installation
Similar to Ubuntu, run the security script:sudo mysql_secure_installationFollow the prompts to secure your installation.
-
Verify the Installation
To check your installation, log in to MariaDB:mysql -u root -p
Fedora
-
Install MariaDB
Open a terminal and run:sudo dnf install mariadb-server -
Start the MariaDB Service
Enable and start the MariaDB service:sudo systemctl start mariadb sudo systemctl enable mariadb -
Secure the Installation
To secure your installation, execute:sudo mysql_secure_installation -
Verify the Installation
Finally, log into MariaDB:mysql -u root -p
Installing MariaDB on Windows
To install MariaDB on Windows, follow these steps:
-
Download the Installer
Visit the MariaDB download page and select the appropriate version of the Windows installer. -
Run the Installer
Once downloaded, double-click the installer to start the installation process. -
Follow the Installation Wizard
- Accept the license agreement.
- Choose the installation type (Typical is recommended for most users).
- If prompted, you can choose to install a sample database.
- Specify the root password that you will use later to access the database.
- Choose the port where MariaDB will run (the default is usually 3306).
-
Finish the Installation
Once you’ve gone through the wizard, click “Finish” to complete the installation. The installer will also set up MariaDB as a Windows service by default, which means it will start automatically when your computer boots. -
Verify the Installation
Open the command prompt and execute:mysql -u root -pEnter your password to log in. If you see the MariaDB prompt, the installation was successful!
Installing MariaDB on macOS
For macOS users, the easiest way to install MariaDB is through Homebrew.
-
Install Homebrew (if not already installed)
Open the terminal and install Homebrew using the following command:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -
Update Homebrew
Make sure your Homebrew is up-to-date:brew update -
Install MariaDB
Now, install MariaDB with the command:brew install mariadb -
Start MariaDB
Start the MariaDB server using the following command:brew services start mariadb -
Secure the Installation
Run the security script:mysql_secure_installationFollow the prompts to secure your installation.
-
Verify the Installation
Connect to your MariaDB server:mysql -u root -pEnter your password, and if you successfully connect, MariaDB is installed and ready to use!
Conclusion
After following the steps outlined for your respective operating system, you should now have MariaDB installed and running seamlessly. Don't forget to secure your installation and explore the myriad of configurations and options that MariaDB offers to customize your database environment. Enjoy building with MariaDB!