Verify if MySQL Database Server is Running on Your Raspberry Pi

A step-by-step guide on how to check if MySQL is installed and running on your Raspberry Pi. …


Updated October 16, 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 how to check if MySQL is installed and running on your Raspberry Pi.

To verify if MySQL is installed and running on your Raspberry Pi, you can follow these steps:

  1. Open a terminal window by clicking on the icon in the menu bar or pressing Ctrl + Alt + T.

  2. Type the following command to check if MySQL is installed:

    sudo dpkg -l | grep mysql
    

    This will list all the packages containing “mysql” and their status (installed or not). Look for a package named mysql-server in the output. If it’s there, it means that MySQL server is installed on your Raspberry Pi.

  3. To check if the MySQL service is running, type:

    sudo systemctl status mysql
    

    This will display information about the MySQL service, including its current state (active or inactive). If the output shows that the service is active and running, you have successfully installed and set up MySQL on your Raspberry Pi.

  4. To connect to the MySQL server from the command line, type:

    sudo mysql -u root -p
    

    This will prompt you for the root password. Enter it when asked, and you’ll be connected to the MySQL server. If you cannot remember your root password, you can reset it by following these steps:

    a. Stop the MySQL service:

    sudo systemctl stop mysql
    

    b. Start the MySQL service with the --skip-grant-tables option to skip the password check:

    sudo mysqld_safe --skip-grant-tables &
    

    c. Connect to MySQL without a password:

    mysql -u root
    

    d. Once connected, run the following command to reset your password:

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
    

    e. Exit MySQL:

    quit
    

    f. Stop the unsafe MySQL service:

    sudo killall mysqld
    

    g. Start the MySQL service normally:

    sudo systemctl start mysql
    
  5. If you want to check the version of MySQL installed on your Raspberry Pi, run:

    mysql --version
    

That’s it! You have successfully checked if MySQL is installed and running on your Raspberry Pi. Now you can use MySQL to create and manage databases on your device.