1080*80 ad

How to Install MySQL 8 on Debian 9

Getting started with a powerful database like MySQL on your server is a fundamental step for many applications. While Debian 9 might be an older release, installing the robust MySQL 8 server is still a common requirement for specific environments. This guide walks you through the process, ensuring you get MySQL 8 up and running smoothly.

MySQL 8 brings significant performance improvements, new features, and enhanced security compared to previous versions. Installing it directly from the official MySQL repositories is the recommended approach to ensure you get the latest updates and features specifically for MySQL 8.

Prerequisites:

Before you begin, make sure you have:

  • A server or virtual machine running Debian 9.
  • Root privileges or a user with sudo access.
  • A stable internet connection to download packages.

Step-by-Step Installation Guide:

Here’s how to install MySQL 8 on your Debian 9 system:

  1. Update Your System:
    It’s always best practice to start with a fully updated package list and system.

    sudo apt update
    sudo apt upgrade -y
    

    This ensures you have the latest information about available packages and apply any pending system updates.

  2. Download the MySQL APT Repository Package:
    MySQL provides a special .deb package that configures the APT repository source list on your system. You need to download this package. Visit the official MySQL APT repository page to find the link for the Debian version corresponding to Debian 9 (which is typically listed as debian). Use wget to download it.

    wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb # (Check official site for the latest version number)
    

    Note: The version number in the filename (0.8.13-1) may change over time. Always check the official MySQL website for the latest version available for Debian.

  3. Install the Repository Package:
    Install the downloaded .deb package using dpkg.

    sudo dpkg -i mysql-apt-config_*_all.deb
    

    During this installation, you will be presented with an interactive menu. Pay close attention here. You need to select which MySQL product you want to install. Navigate the menu to choose MySQL Server & Cluster and then select the specific MySQL Server version, which should be mysql-8.0. Choose the defaults for other components unless you have specific needs. Select Ok when done.

  4. Update APT Package List Again:
    After adding the new repository, you must update your APT package list so your system knows about the new packages available from the MySQL repository.

    sudo apt update
    
  5. Install the MySQL Server:
    Now that the repository is configured and updated, you can install the MySQL server package.

    sudo apt install mysql-server
    

    The system will calculate dependencies and prompt you to confirm the installation. Type Y and press Enter. During the installation process, you will likely be asked to set a root password for MySQL. Choose a strong, secure password and remember it. You may also be asked about the authentication plugin. The recommended default (Use Strong Password Encryption) is usually the best choice for security.

  6. Run the MySQL Security Script:
    This is a crucial post-installation step for securing your new MySQL installation.

    sudo mysql_secure_installation
    

    This script will guide you through several important security configurations:

    • Validating the password strength of the root user (optional, can set up the plugin).
    • Changing the root password (if you didn’t set one during installation or want to change it).
    • Removing anonymous users.
    • Disallowing remote root login.
    • Removing the test database and access to it.
    • Reloading privilege tables to apply changes.

    It is highly recommended to answer ‘Y’ (Yes) to most of these prompts to enhance the security of your database server.

  7. Verify the Installation:
    You can check if the MySQL service is running and verify the installed version.

    sudo systemctl status mysql
    

    You should see output indicating the service is active (running). You can also try logging in as the root user to confirm access:

    sudo mysql -u root -p
    

    Enter the root password you set earlier. If you see the MySQL prompt (mysql>), the installation was successful. Type exit; to leave the MySQL prompt.

  8. Manage the MySQL Service (Optional):
    You can use systemctl to manage the MySQL service:
    bash
    sudo systemctl start mysql # Start the service
    sudo systemctl stop mysql # Stop the service
    sudo systemctl restart mysql # Restart the service
    sudo systemctl enable mysql # Enable service to start on boot
    sudo systemctl disable mysql # Disable service from starting on boot

Post-Installation and Security:

  • Always run mysql_secure_installation immediately after installing MySQL.
  • Avoid using the root MySQL user for applications. Instead, create specific users with only the necessary privileges for your databases.
  • If you need to access the database remotely, configure your firewall (ufw or firewalld) to allow connections to the MySQL port (default 3306) only from trusted IP addresses.

Conclusion:

By following these steps, you have successfully installed MySQL 8 on your Debian 9 server. You now have a powerful and secure database system ready to host your applications and data. Remember to manage your users and secure your installation appropriately for your environment.

Source: https://kifarunix.com/install-mysql-8-on-debian-9/

900*80 ad

      1080*80 ad