Table of Contents
What you will read?
MySQL is a powerful and widely used open-source relational database system. On Arch Linux 6.12, installing MySQL (known as MariaDB in most Arch repositories) is straightforward.
Step 1: Update Your System
Before installing anything, make sure your Arch system is up-to-date to avoid dependency issues.
sudo pacman -Syu
Step 2: Install MySQL (MariaDB)
In Arch Linux, MariaDB serves as a drop-in replacement for MySQL and is fully compatible with it. Install it with:
sudo pacman -S mariadb
If you specifically need Oracle MySQL, you can install it from the AUR (Arch User Repository) using an AUR helper like yay:
yay -S mysql
Step 3: Initialize the Database
Before running MySQL (or MariaDB) for the first time, initialize the database directory:
sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
This sets up the initial system tables required for MySQL to function properly.
Step 4: Enable and Start the Service
Start the MySQL (MariaDB) service and enable it to launch automatically on boot:
sudo systemctl start mariadb
sudo systemctl enable mariadb
Check the status to confirm it’s running:
sudo systemctl status mariadb
Step 5: Secure the Installation
Run the included security script to remove insecure defaults and set up a root password:
sudo mysql_secure_installation
You’ll be asked to:
-
Set the MySQL root password
-
Remove anonymous users
-
Disable remote root login
-
Remove test databases
Press Y for all recommended options.
Step 6: Access the MySQL Shell
Once secured, you can log in to the MySQL console:
mysql -u root -p
Enter the password you created during the secure installation. From here, you can manage databases, users, and permissions.
Step 7: Test Your Installation
To confirm MySQL is working correctly, check its version:
mysql --version
You should see output showing the installed version of MariaDB or MySQL.
You can also create a quick test database:
CREATE DATABASE test_db;
SHOW DATABASES;
Step 8: (Optional) Enable Remote Access
If you want to allow connections from other systems, edit the configuration file:
sudo nano /etc/my.cnf.d/server.cnf
Locate the bind-address line and set it to:
bind-address = 0.0.0.0
Then restart the service:
sudo systemctl restart mariadb
Make sure your firewall allows port 3306 for external access.
You’ve successfully installed and configured MySQL (MariaDB) on Arch Linux 6.12. Your system is now ready to host databases for web servers, applications, or testing environments. For more Linux server setup tutorials, optimization tips, and step-by-step guides, visit DropVPS — your hub for practical server management knowledge.
