How to Install and configure MySQL on Arch-based Linux Distributions(Manjaro)
MySQL is an open-source relational database management system developed by Oracle based on structured query language (SQL). It is primarily written in C and C++ programming languages and licensed under the GNU Public License. The client-end API is used to query, filter, sort, group, and modify data stored in the database table in the form of rows and columns. This article is a step-by-step guide for installing and configuring MySQL server on an Arch-based Linux system.
Installation of MySQL on Manjaro
Follow the below steps to install the MySQL database.
Step 1: We will update and upgrade our system by executing the following command
$ sudo pacman -Syu
Step 2: Install MySQL from the official repository using pacman package manager
$ sudo pacman -S mysql
Step 3: Now, verify the installation by running the below command.
$ mysqld --version
Step 4: Start MySQL server by using the systemctl command.
$ sudo systemctl start mysqld $ sudo systemctl status mysqld
Step 5: Once again use systemctl command to enable MySQL service. After command execution, MySQL will restart whenever our machine boots up.
$ sudo systemctl enable mysqld
Configuring MySQL on Manjaro
Follow the below steps to configure MySQL on Manjaro.
Step 1: Start the MySQL configuration script as the sudo user. In this step, we’ll be prompted to change our MySQL installation’s security settings.
$ sudo mysql_secure_installation
Step 2: Now, log into the MySQL command-line interface as the root user.
$ sudo mysql
Step 3: Create a new user with the following command.
> CREATE USER ‘<username>’@’localhost’ IDENTIFIED BY ‘<password>’;
Step 4: Grant all privileges to the newly created user.
> GRANT ALL PRIVILEGES ON *.* TO ‘<username>’@’localhost’ WITH GRANT OPTION;
Step 5: Free up any cached memory and exit the MySQL client.
> FLUSH PRIVILEGES; > exit
Step 6: Now, log in with the newly created user.
> mysql -u testuser -p
Step 7: At this point, we have successfully installed and configured MySQL on our Manjaro machine.
> CREATE DATABASE <dbname>;
Run the below command to see the list of available databases.
> SHOW DATABASES