Introduction:
When it comes to installing MariaDB on Arch Linux, you might encounter issues with conflicts and deprecation warnings, as I did. Additionally, much of the information available online might be outdated. This guide will help you navigate the installation process, provide essential configuration steps, and teach you how to manage users effectively. By the end, you'll have a secure and functional MariaDB setup on your Arch Linux system and be able to also use it to manage MySQL Database.
Step 1: System Upgrade
sudo pacman -Syu
Step 2: Installing MariaDB
sudo pacman -S mariadb
Step 3: Initializing MariaDB
sudo mariadb-install-db --user=mysql --basedir=/usr
--datadir=/var/lib/mysql
Step 4: Starting and Managing MariaDB
sudo systemctl start mariadb
sudo systemctl stop mariadb
sudo systemctl enable mariadb
Step 5: Securing Your MariaDB Installation
- Run
mariadb-secure-installation
to secure your installation: - You'll be prompted to set a new root password, remove anonymous users, disallow remote root login, and remove the test database. Follow the on-screen instructions.
sudo mariadb-secure-installation
Creating a New User
- Log into the MariaDB command-line interface as the root user:
- Create a new user, replacing
userName
andyourPassword
with your desired credentials: - Grant all privileges to the new user, replacing
userName
: - Flush privileges and exit the MariaDB client:
- Log in with the newly created user (if needed):
- Create a new database:
- To view available databases:
- Log into the MariaDB command-line interface:
- Delete a user using the
DROP USER
statement, replacinguserName
: - After running the
DROP USER
command, flush the privileges: - Exit the MariaDB command-line interface:
sudo mariadb
CREATE USER 'userName'@'localhost' IDENTIFIED BY 'yourPassword';
GRANT ALL PRIVILEGES ON *.* TO 'userName'@'localhost' WITH GRANT
OPTION;
FLUSH PRIVILEGES; exit
mariadb -u userName -p
CREATE DATABASE yourDatabaseName;
SHOW DATABASES;
Deleting a user
If you created a user by mistake which i did and you want to remove it, you can use the following commands to delete the user:
sudo mariadb
DROP USER 'userName'@'localhost';
FLUSH PRIVILEGES;
exit
Please use these commands with caution, as they are irreversible. Ensure you are deleting the correct user before proceeding.
To Wrap It Up
Installing and managing MariaDB on Arch Linux can be a straightforward process when you have the right guidance. By following the steps outlined in this guide, you can ensure that your MariaDB installation is up to date, secure, and tailored to your specific needs. From initializing the database to creating and managing users
It's important to keep in mind that MariaDB is a powerful database management system, and it can serve a wide range of applications, from personal projects to enterprise-level solutions. With the knowledge gained from this guide, you are better equipped to harness the capabilities of MariaDB and make it work seamlessly within your Arch Linux system.
As you continue your journey with MariaDB, remember to stay updated with best practices and security measures, and always exercise caution when making irreversible changes, such as deleting users or databases. With this newfound understanding, you can confidently use MariaDB to store, retrieve, and manage your data effectively on your Arch Linux system.