Announcement

Collapse
No announcement yet.

Install MySQL on Ubuntu 24.04

Collapse
X
Collapse
  •  

  • Install MySQL on Ubuntu 24.04


    MySQL is a reliable and widely used DBMS that utilizes SQL and a relational model to manage data. MySQL is installed as part of LAMP in Linux, but you can install it separately.Even in Ubuntu 24.04, installing MySQL is straightforward. This guide outlines the steps to follow. Read on!

    Step-By-Step Guide to Install MySQL on Ubuntu 24.04

    If you have a user account on your Ubuntu 24.04 and have sudo privileges, installing MySQL requires you to follow the procedure below.

    Step 1: Update the System’s Repository

    When installing packages on Ubuntu, you should update the system’s repository to refresh the sources list. Doing so ensures the MySQL package you install is the latest stable version.

    $ sudo apt update




    Step 2: Install MySQL Server

    Once the package index updates, the next step is to install the MySQL server package using the below command.

    $ sudo apt install mysql-server




    After the installation, start the MySQL service on your Ubuntu 24.04.

    $ sudo systemctl start mysql.service




    Step 3: Configure MySQL

    Before we can start working with MySQL, we need to make a couple of configurations. First, access the MySQL shell using the command below.

    $ sudo mysql




    Once the shell opens up, set a password for your ’root’ using the below syntax.

    ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘your_password’;


    We’ve also specified to use the mysql_native_password authentication method.



    Exit the MySQL shell.

    exit;




    Step 4: Run the MySQL Script

    One interesting feature of MySQL is that it offers a script that you should run to quickly set it up. The script prompts you to specify different settings based on your preference. For example, you will be prompted to set a password for the root user. Go through each prompt and respond accordingly.

    $ sudo mysql_secure_installation




    Step 5: Modify the Authentication Method

    After successfully running the MySQL installation script, you should change the authentication method and set it to use the auth_socket plugin.

    Start by accessing your MySQL shell using the root account.

    $ mysql -u root -p




    Once logged in, run the below command to modify the authentication plugin.

    ALTER USER ‘root’@’localhost’ IDENTIFIED WITH auth_socket;




    Step 6: Create a MySQL User

    So far, we have only access to MySQL using the root account. We should create a new user and specify what privileges they should have. When creating a new user, you must add their username and the login password using the syntax below.

    create user ‘username’@’localhost’ IDENTIFIED BY ‘password’;




    Now that the user is created, we need to specify what privileges the user has when using MySQL. For instance, you can give them privileges, such as CREATE, ALTER, etc., on a specific or all the databases.

    Here’s an example where we’ve specified a few privileges to the added user on all available databases. Feel free to specify whichever privileges are ideal for your user.

    GRANT CREATE, ALTER, INSERT, UPDATE, SELECT on *.* TO ‘username’@’localhost’ WITH GRANT OPTION;




    For the new user and the privileges to apply, flush the privileges and exit MySQL.

    flush privileges;




    Step 7: Confirm the Created User

    As the last step, we should verify that our user can access the database and has the specified privileges. Start by checking the MySQL service to ensure it is running.

    $ sudo systemctl status mysql




    Next, access MySQL using the credentials of the user you added in the previous step.

    $ mysql -u username -p




    A successful login confirms that you’ve successfully installed MySQL, configured it, and added a new user.

    Conclusion

    MySQL is a relational DBMS widely used for various purposes. It supports SQL in managing data, and this post discusses all the steps you should follow to install it on Ubuntu 24.04. Hopefully, you’ve installed MySQL on your Ubuntu 24.04 with the help of the covered steps.





    More...
      Posting comments is disabled.

    Categories

    Collapse

    Article Tags

    Collapse

    There are no tags yet.

    Latest Articles

    Collapse

    • HAProxy on Ubuntu: Load Balancing and Failover for Resilient Infrastructure
      by Kasimba



      by german.suarez


      Introduction

      In today’s fast-paced digital landscape, ensuring the availability and performance of applications is paramount. Modern infrastructures require robust solutions to distribute traffic efficiently and maintain service availability even in the face of server failures. Enter HAProxy, the de facto standard for high-performance load balancing and failover.


      This article...
      Today, 03:00 PM
    • Providing a license for package sources
      by Kasimba
      Arch Linux hasn't had a license for any package sources (such as PKGBUILD files) in the past, which is potentially problematic. Providing a license will preempt that uncertainty.

      In RFC 40 we agreed to change all package sources to be licensed under the very liberal 0BSD license. This change will not limit what you can do with package sources. Check out the RFC for more on the rationale and prior discussion.

      Before we make this change, we will provide contributors with...
      11-19-2024, 09:21 AM
    • Linux Binary Analysis for Reverse Engineering and Vulnerability Discovery
      by Kasimba



      by George Whittaker


      Introduction

      In the world of cybersecurity and software development, binary analysis holds a unique place. It is the art of examining compiled programs to understand their functionality, identify vulnerabilities, or debug issues—without access to the original source code. For Linux, which dominates servers, embedded systems, and even personal computing, the skill of binary analysis is...
      11-18-2024, 07:10 PM
    • Ubuntu vs Debian: Linux Distributions Compared Deep Dive
      by Kasimba
      Debian and Ubuntu are two popular Linux distributions. In this deep dive we will guide you on the key differences between them from perspective of both corporate enterprise and personal productivity or pleasure usage. After reading this blog post you should be in a better position to decide to select Ubuntu or Debian.
      Stewardship, Licensing, Community and Cost

      Where as Debian is 100% fully committed to free software as defined by the Debian Free Software Guidelines, Ubuntu is created...
      11-17-2024, 08:30 PM
    • Debian Backup and Recovery Solutions: Safeguard Your Data with Confidence
      by Kasimba



      by George Whittaker


      Introduction

      In the digital age, data loss is a critical concern, and effective backup and recovery systems are vital for any Debian system administrator or user. Debian, known for its stability and suitability in enterprise, server, and personal computing environments, offers a multitude of tools for creating robust backup and recovery solutions. This guide will explore these solutions,...
      11-13-2024, 05:30 PM
    • Installing Development Tools on Debian: Setting Up Compilers, Libraries, and IDEs for a Robust Development Environment
      by Kasimba



      by George Whittaker


      Introduction

      Debian is one of the most trusted and stable Linux distributions, making it a top choice among developers and system administrators. Setting up a powerful development environment on Debian involves installing the right tools, compilers, libraries, and Integrated Development Environments (IDEs) that can support various programming languages and workflows. This guide provides...
      11-07-2024, 11:22 PM
    Working...
    X