Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Databases»MySQL»How To Install MySQL on Debian 9 (Stretch)

    How To Install MySQL on Debian 9 (Stretch)

    RahulBy RahulMarch 27, 20183 Mins ReadUpdated:July 5, 2019

    MySQL is the most popular relational database management system. As an assumption MySQL is used by every third website running on www. MySQL installation on a Linux is very straightforward. You can simply install MySQL on a Debian system from its base repositories. But The Debian team replaced MySQL with MariaDB as the default database from Debian 9 Stretch. This tutorial will help you to install MySQL on Debian 9 systems with the latest MySQL version.

    Step 1 – Prerequisites

    Login to your Debian 9 system using shell access. For remote systems connect with SSH. Windows users can use Putty or other alternatives applications for SSH connection.

    ssh [email protected]
    

    Run below commands to upgrade the current packages to the latest version.

    sudo apt update 
    sudo apt upgrade
    

    Step 2 – Configure MySQL PPA

    MySQL team provides official MySQL PPA for Debian Linux. You can download and install the package on your Debian system, which will add PPA file to your system. Run below command to enable PPA.

    wget http://repo.mysql.com/mysql-apt-config_0.8.13-1_all.deb
    sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb
    

    During the installation of MySQL apt config package, It will prompt to select MySQL version to install. Select the MySQL 5.7 or 5.6 option to install on your system.

    Install MySQL on Debian 9 Stretch

    Step 3 – Install MySQL on Debian 9

    Your system is ready for the MySQL installation. Run the following commands to install MySQL on a Debian machine.

    sudo apt update 
    sudo apt install mysql-server
    

    The installation process will prompt for the root password to set as default. Input a secure password and same to confirm password window. This will be MySQL root user password required to log in to MySQL server.

    Install MySQL on Debian 9

    Install MySQL on Debian Stretch

    Step 4 – Secure MySQL Installation

    Execute the below command on your system to make security changes on your Database server. This will prompt some questions. The do the high security provide all answers to yes.

    First start the MysQL service if not started:

    sudo systemctl restart mysql
    

    Then run below command:

    sudo mysql_secure_installation
    

    Step 5 – Connect MySQL

    The MySQL server has been installed on your system. Now connect to the MySQL database using the command line.

    mysql -u root -p
    
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 5
    Server version: 5.7.21 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql>
    
    database Debian 9 Debian Stretch MySQL
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow To Install LAMP (Apache, MySQL, PHP) on Debian 8 Jessie
    Next Article How to Install JAVA 8 on Ubuntu 18.04/16.04, Linux Mint 19/18

    Related Posts

    Backup MySQL Databases to Amazon S3 (Shell Script)

    Updated:May 28, 20222 Mins Read

    How to Install MariaDB on Ubuntu 22.04

    Updated:May 28, 20222 Mins Read

    How To Install Linux, Nginx, MySQL, & PHP (LEMP Stack) on Ubuntu 22.04

    Updated:April 7, 20227 Mins Read

    How To Install MySQL Server on Ubuntu 22.04

    Updated:April 6, 20224 Mins Read

    How to Install Apache, MySQL, PHP (LAMP Stack) on Ubuntu 22.04

    Updated:June 28, 20225 Mins Read

    How To Install MariaDB on Debian 11

    4 Mins Read

    25 Comments

    1. Dragos Balaceanu on June 24, 2021 3:37 pm

      A very valuable support !

      Reply
    2. John on April 8, 2021 8:39 am

      Another great article, thank you

      Reply
    3. Eder on January 31, 2021 1:02 pm

      Perfect!! It helped me a lot.

      Reply
    4. DVSSN Raju on October 8, 2020 5:01 pm

      Thanks bro, worked perfectly for Debian 4.19

      Reply
    5. Jimmy Ilenloa on July 21, 2020 8:19 pm

      it worked. thank you very much

      Reply
    6. Jairo Sanchez on October 18, 2019 4:24 pm

      Thank you. Install in Debian 9.9 . ,10.1.41 MariaDB

      Reply
    7. Moriort on October 15, 2019 7:25 pm

      Thanks dude!

      Reply
    8. Pierre on July 26, 2019 1:14 pm

      Thanks man!

      Reply
    9. Luis Morales on July 22, 2019 5:09 pm

      Hi Rahul, My name is Luis.

      I have install mysql 8 on debian 10 for project the university,

      I have tried everything but I have not achieved it, do you think you can guide me?

      Regards

      Reply
    10. Voja on July 3, 2019 9:40 am

      Great tutorial, but you need to change the version of the script, otherwise it will just install mariadb again.
      It should be: mysql-apt-config_0.8.13-1_all.deb

      Reply
      • Rahul on July 5, 2019 7:49 am

        Thanks Voja, Tutorial has been updated.

        Reply
    11. Joel on May 23, 2019 11:00 am

      This is BS and will damage your computer.
      To get mysql log in as root with su and password.
      Then type “apt-get install mysql-server”
      And it will load automatically!

      Reply
      • Helio on August 13, 2019 2:26 am

        I just tried your suggestion, you know… for shits and giggles…

        Package ‘mysql-server’ has no installation candidate

        Reply
    12. Grzegorz on May 9, 2019 5:48 pm

      Not working – it install Maria !!!

      Reply
      • Azael on June 25, 2019 8:05 pm

        Found the problem, maybe they PPA provided here is not signed and debian is ignoring him, this is the most recent PPA:
        https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
        just wget and dpkg and you will success.

        Reply
    13. Yar on April 9, 2019 7:29 pm

      It not working! It installs MariaDB on Debian 9.6! How to install Mysql 8, not MariaDB?

      Reply
    14. jonny on April 5, 2019 8:24 am

      ahoj 🙂

      Reply
    15. Amol Gupta on April 2, 2019 10:36 am

      How do I install a particular version. I need to install the version 5.7 (not the latest version 8).

      Reply
    16. Ksenia on April 2, 2019 10:20 am

      Thanks a lot, Rahul! A quick question. Installed on my VirtualBox, but the prompt says MariaDB. Why is it so?

      Reply
    17. Alfredo on March 26, 2019 7:27 pm

      Hello Raul.. Can you update this.. adding mysql workbench,. is giving trouble to install it..
      Thanks

      Reply
    18. smegma on January 9, 2019 7:47 pm

      mysql_secure_installation

      Securing the MySQL server deployment.

      Enter password for user root:
      Error: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

      Reply
    19. Seb on September 13, 2018 9:17 am

      Awesome guide for a newbie like me ! One specification : For step 2, if the currently selected product is already the correct on e(mysql 5.7) then you should just navigate down to “ok” rather than pressing Enter (otherwise you’ll get in a loop..)

      Reply
    20. zzzz on August 23, 2018 3:15 am

      Thank you.

      Reply
    21. PHILEMON SUNDAY on July 14, 2018 7:33 pm

      Cool….. I love this blog

      Reply
    22. MS on June 22, 2018 5:35 am

      This was great Rahul, thank you. Good detailing, and straight forward.

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • Filesystem Hierarchy Structure (FHS) in Linux
    • How to accept user input in Python
    • What is difference between var, let and const in JavaScript?
    • What is CPU? – Definition, Types and Parts
    • What is the /etc/aliases file
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.