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: Run the following command before starting mysqld
$ mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
Step 5: Start the MySQL server by using the systemctl command.
$ sudo systemctl start mysqld
$ sudo systemctl status mysqld
Step 6: 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;
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
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!