Guide to Installing MariaDB/MySQL on Arch Linux
Introduction
Installing MariaDB or MySQL on Arch Linux can be a daunting task, especially if you're not familiar with the intricacies of the Arch environment. This guide aims to be a comprehensive, one-stop resource to help you get MariaDB/MySQL up and running on your Arch Linux machine.
Preparation
Before we dive into the installation process, ensure your system is up to date. Run the following command:
sudo pacman -Syu
This updates your system and minimizes the chances of encountering issues during the installation process.
Step 1: Installing MariaDB/MySQL
Arch Linux offers both MariaDB and MySQL for installation. MariaDB is a community-developed fork of MySQL, and it's often recommended due to its active community and consistent updates.
To install MariaDB, use the following command:
sudo pacman -S mariadb
Alternatively, for MySQL, use:
sudo pacman -S mysql
Step 2: Initializing the Database
Once the installation is complete, you need to initialize the database directory. This step is crucial for setting up the system tables and preparing the database for use.
Run the following command:
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
If the initialization is successful, you will see a message indicating that the system tables have been installed.
Step 3: Starting the MariaDB Service
With the database initialized, you can now start the MariaDB service. Use the command below:
sudo systemctl start mysqld
In case of errors, check the status of the service for more details:
systemctl status mariadb.serviceand
and
journalctl -xe
Step 4: Securing the Installation
Securing your MariaDB installation is an important step to ensure your database is protected. Run the following command to start the secure installation process:
sudo mysql_secure_installation
You'll be prompted to set the root password and make several security-related decisions. Follow the prompts to complete the setup.
Step 5: Creating Your First Database
Now that MariaDB/MySQL is up and running, you can create your first database. Access the MariaDB/MySQL shell with the command:
sudo mysql -u root -p
Enter the root password you set during the secure installation process. Once in the shell, create a new database with:
CREATE DATABASE mydatabase;
Replace mydatabase
with your desired database name.
Conclusion
Installing MariaDB/MySQL on Arch Linux can be challenging, but by following this guide, you should have a functioning database system ready for use. Remember to keep your system and database software updated to avoid potential issues. If you encounter any problems, refer to the Arch Linux forums and documentation for additional support.
Summary
System Update:
sudo pacman -Syu
Install MariaDB:
sudo pacman -S mariadb
Initialize Database:
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
Start MariaDB Service:
sudo systemctl start mysqld
Secure Installation:
sudo mysql_secure_installation
Create Database:
CREATE DATABASE mydatabase;
Good luck, and happy coding! ๐
Subscribe to my newsletter
Read articles from Romjan D. Hossain directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Romjan D. Hossain
Romjan D. Hossain
Exploring new/old technologies every day. Its just amazing.....!