Install MySQL on Ubuntu

Install MySQL on Ubuntu

Install MySQL on Ubuntu

MySQL is one of the most popular open-source database management systems. Installing MySQL on Ubuntu is straightforward, whether setting up a database for a web application or just exploring the world of databases. This guide walks you through the process.

Step 1: Update Your System

Before installing MySQL, it's important to ensure your system is up to date.

  1. Open your terminal.
  2. Run the following commands to update and upgrade the package list:
    sudo apt update sudo apt upgrade

Step 2: Install MySQL

Ubuntu includes MySQL in its default package repositories.

  1. To install MySQL, run:
    sudo apt install mysql-server
  2. Confirm the installation by typing Y when prompted.

Step 3: Start and Enable MySQL Service

After installation, start the MySQL service and ensure it runs automatically on system boot.

  1. Start the MySQL service:
    sudo systemctl start mysql
  2. Enable it to start at boot:
    sudo systemctl enable mysql

Step 4: Secure the Installation

MySQL includes a security script to help configure settings for enhanced security.

  1. Run the security script:
    sudo mysql_secure_installation
  2. Follow the prompts to:
    • Set a root password.
    • Remove anonymous users.
    • Disallow remote root logins.
    • Remove test databases.
    • Reload privilege tables.

Step 5: Test the Installation

Ensure that MySQL is installed and running properly.

  1. Check the status of the MySQL service:

    sudo systemctl status mysql

    If it says "active (running)," MySQL is running.

  2. Log in to MySQL as the root user:

    sudo mysql -u root -p

    Enter the password you set during the secure installation.

  3. After logging in, test with a simple query:

    SHOW DATABASES;

    Exit MySQL by typing exit.

Optional: Install MySQL Workbench

If you prefer a graphical interface to manage your databases, consider installing MySQL Workbench.

  1. Install it using the command:
    sudo apt install mysql-workbench

Final Notes

Congratulations! You now have MySQL installed and ready to use on your Ubuntu system. From here, you can create databases, manage users, and integrate MySQL with your applications.

If you have any questions or run into issues, please leave a comment below!

Soeng Souy

Soeng Souy

Website that learns and reads, PHP, Framework Laravel, How to and download Admin template sample source code free.

Post a Comment

CAN FEEDBACK
close