Technology Encyclopedia Home >How to install and configure MySQL on Pop!_OS?

How to install and configure MySQL on Pop!_OS?

To install and configure MySQL on Pop!_OS, follow these steps:

Installation

  1. Update the System:

    sudo apt update && sudo apt upgrade
    
  2. Install MySQL Server:

    sudo apt install mysql-server
    
  3. Secure the Installation:
    During the installation, you'll be prompted to set a root password and answer a few security questions. Follow the on-screen instructions.

Configuration

  1. Start and Enable MySQL Service:

    sudo systemctl start mysql
    sudo systemctl enable mysql
    
  2. Run the Security Script:
    This script helps secure the MySQL installation by setting a password for the root user, removing anonymous users, disallowing root login remotely, and removing the test database.

    sudo mysql_secure_installation
    
  3. Login to MySQL:

    sudo mysql -u root -p
    
  4. Create a New Database (Optional):

    CREATE DATABASE mydatabase;
    
  5. Create a New User and Grant Privileges (Optional):

    CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
    GRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'localhost';
    FLUSH PRIVILEGES;
    
  6. Exit MySQL:

    EXIT;
    

Example Usage

To connect to the MySQL server using the newly created user:

mysql -u myuser -p mydatabase

Cloud-Related Recommendation

If you're looking for a managed database service, consider using Tencent Cloud's Cloud Database MySQL. It offers automated management, high availability, and scalability, which can simplify database operations and enhance reliability.

By following these steps, you should have MySQL installed and configured on your Pop!_OS system.