Verifying the Installation of MySQL Server on Your Raspberry Pi

A step-by-step guide on checking if MySQL is installed and running on your Raspberry Pi. Learn how to ensure that your database server is up and running. …


Updated September 7, 2023

Need help with your Raspberry Pi?
Contact Me!

Do you love silly Raspberry Pi Projects?
Check out my this YouTube Channel!


A step-by-step guide on checking if MySQL is installed and running on your Raspberry Pi. Learn how to ensure that your database server is up and running.

In this article, we will go over the steps required to check if MySQL is properly installed on your Raspberry Pi. MySQL is a popular open-source database management system that is commonly used for web development projects. Ensuring that it is installed and running correctly can be crucial for your project’s success.

Here are the steps you should follow:

  1. First, make sure that you have a working Raspberry Pi with a fresh installation of Raspbian or another compatible operating system.

  2. Open up a terminal window by pressing CTRL + ALT + T on your keyboard. This will allow you to execute commands and check the status of MySQL.

  3. Type in the following command to verify if MySQL is installed:

sudo dpkg -l | grep mysql-server

This command uses the dpkg package manager to list all installed packages on your Raspberry Pi, and then filters the output with grep to find any mention of “mysql-server”. If you see a line that starts with “ii” followed by “mysql-server”, it means that MySQL is installed. For example:

ii  mysql-server                       5.7.28-0ubuntu0.18.04.3                   amd64        MySQL database server binaries and system database setup

If you do not see any output, it means that MySQL is not installed on your Raspberry Pi. You can install it using the following command:

sudo apt-get update && sudo apt-get install mysql-server
  1. After verifying that MySQL is installed, check if the server is running by executing this command:
sudo systemctl status mysql

You should see output similar to this:

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-05-21 10:38:47 UTC; 9min ago
 Main PID: 868 (mysqld)
    Tasks: 27 (limit: 4915)
   Memory: 108.0M
   CGroup: /system.slice/mysql.service
           └─868 /usr/sbin/mysqld

If the output shows that the server is “active” and running, you’re all set! If it says “inactive” or something similar, try starting the server with this command:

sudo systemctl start mysql
  1. To verify that MySQL is accessible from your terminal, run the following command:
mysql -u root -p

This will prompt you to enter your MySQL password. If you have not set a password for the “root” user yet, simply press ENTER when prompted.

  1. Once logged in, you can check the version of MySQL by running:
SELECT VERSION();

This will display the current version number. For example:

+-----------+
| VERSION() |
+-----------+
| 5.7.28    |
+-----------+
1 row in set (0.00 sec)

If you see a similar output, it means that MySQL is installed and running on your Raspberry Pi. You can now use it for your web development projects!

Remember to always keep your system updated with the latest security patches and back up your data regularly to avoid any potential issues. Good luck with your project!