{"id":2496,"date":"2024-10-23T22:35:25","date_gmt":"2024-10-23T17:05:25","guid":{"rendered":"https:\/\/www.hostbet.in\/blog\/?p=2496"},"modified":"2025-01-24T15:04:58","modified_gmt":"2025-01-24T09:34:58","slug":"how-to-install-mysql-on-ubuntu","status":"publish","type":"post","link":"https:\/\/www.hostbet.in\/blog\/how-to-install-mysql-on-ubuntu\/","title":{"rendered":"How To Install MySQL on Ubuntu 24- Quick Tutorial 2025"},"content":{"rendered":"\n<p>When it comes to installing MySQL on Ubuntu for relational database management systems is a crucial step in setting up a web application stack. This guide will walk you through the process of how to install MySQL on Ubuntu.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_71 counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.hostbet.in\/blog\/how-to-install-mysql-on-ubuntu\/#Prerequisites_to_Install_MySQL_on_Ubuntu_24\" title=\"Prerequisites to Install MySQL on Ubuntu 24\">Prerequisites to Install MySQL on Ubuntu 24<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.hostbet.in\/blog\/how-to-install-mysql-on-ubuntu\/#Update_Package_Lists\" title=\"Update Package Lists\">Update Package Lists<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.hostbet.in\/blog\/how-to-install-mysql-on-ubuntu\/#Install_MySQL_Server\" title=\"Install MySQL Server\">Install MySQL Server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.hostbet.in\/blog\/how-to-install-mysql-on-ubuntu\/#Secure_the_Installation\" title=\"Secure the Installation\">Secure the Installation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.hostbet.in\/blog\/how-to-install-mysql-on-ubuntu\/#Check_MySQL_Service\" title=\"Check MySQL Service\">Check MySQL Service<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.hostbet.in\/blog\/how-to-install-mysql-on-ubuntu\/#Log_into_MySQL\" title=\"Log into MySQL\">Log into MySQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.hostbet.in\/blog\/how-to-install-mysql-on-ubuntu\/#Create_a_Database\" title=\"Create a Database\">Create a Database<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.hostbet.in\/blog\/how-to-install-mysql-on-ubuntu\/#Create_a_New_User\" title=\"Create a New User\">Create a New User<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.hostbet.in\/blog\/how-to-install-mysql-on-ubuntu\/#Exit_MySQL\" title=\"Exit MySQL\">Exit MySQL<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.hostbet.in\/blog\/how-to-install-mysql-on-ubuntu\/#Final_Thought_on_Install_MySQL_on_Ubuntu\" title=\"Final Thought on Install MySQL on Ubuntu\">Final Thought on Install MySQL on Ubuntu<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Prerequisites_to_Install_MySQL_on_Ubuntu_24\"><\/span>Prerequisites to Install MySQL on Ubuntu 24<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>VPS: Get Powerful VPS Hosting: Visit HostBet.in<\/li>\n\n\n\n<li>Access to your VPS: You should have the IP address and password provided by HostBet. (Once you purchase a VPS hosting plan from any VPS hosting provider, you\u2019ll typically receive an email with the IP address, password, and other details:)<\/li>\n\n\n\n<li>SSH client: A tool like PuTTY or Terminal (on macOS\/Linux) to connect to your VPS.  <strong>How to <a href=\"https:\/\/www.hostbet.in\/blog\/install-apache-server-on-ubuntu\/#Connect_to_Your_VPS_Hosting\">Connect to Your VPS Hosting via SSH\/PuTTY&nbsp;<\/a><\/strong><\/li>\n<\/ul>\n\n\n\n<p>Remember that before installing any components, such as Linux, Apache, MySQL, or PHP, always start by updating your package index to ensure you are getting the latest version of MySQL.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Update_Package_Lists\"><\/span><strong>Update Package Lists<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>To update packages, you need to ensure you have the latest packages. If not, then you run the following command:\u00a0<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-5-color has-black-background-color has-text-color has-background has-link-color wp-elements-5d19476d36c90a67e7e4037f31e52ca9\"><code><strong>Command: sudo apt update<\/strong><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Install_MySQL_Server\"><\/span><strong>Install MySQL Server<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Next, install the MySQL server package.<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-5-color has-black-background-color has-text-color has-background has-link-color wp-elements-ad2a627814a9680f1c43958fc151a5bd\"><code><strong>Command: sudo apt install mysql-server<\/strong><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Secure_the_Installation\"><\/span><strong>Secure the Installation<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Once the installation is complete, run the script to improve your MySQL installation&#8217;s security.<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-5-color has-black-background-color has-text-color has-background has-link-color wp-elements-8226ef28f03f7cdf2a982b05aa169e83\"><code><strong>Command: sudo mysql_secure_installation<\/strong><\/code><\/pre>\n\n\n\n<p>Once you enter this command in the terminal, sudo mysql_secure_installation, you will see the prompt.<\/p>\n\n\n\n<p>To secure your MySQL installations,&nbsp; you need to follow the prompts during the mysql_secure_installation script. 1. Create a strong root password; 2. Remove anonymous users; 3. Disable remote root login; 4. Delete the test database. Answering &#8220;yes&#8221; to all prompts is generally recommended for optimal security.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Check_MySQL_Service\"><\/span>Check MySQL Service<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Ensure MySQL service is running.<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-5-color has-black-background-color has-text-color has-background has-link-color wp-elements-94e424b2d0c559e09fa4ca92f54675f0\"><code><strong>Command: sudo systemctl status mysql<\/strong><\/code><\/pre>\n\n\n\n<p>Basically, this command is used to verify the status of your MySQL services; that means you can easily verify the status if your MySQL is running, stopped, or has encountered any errors.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Log_into_MySQL\"><\/span>Log into MySQL<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>To manage your MySQL database, log in to the MySQL root user.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-7b5b3c51a5c7b222e0e53b0a85c31f0f\"><code><strong>Command:<\/strong> <strong>sudo mysql -u root -p<\/strong><\/code><\/pre>\n\n\n\n<p>You must enter the root password you set up earlier.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Create_a_Database\"><\/span>Create a Database<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>After logging in, you can easily create your first database.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-81a2e7cdbe3eefdf3312e28212f6999f\"><code><strong>Command: CREATE DATABASE  your_database_name;<\/strong><\/code><\/pre>\n\n\n\n<p>Replace your_database_name with the desired name for your database.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Create_a_New_User\"><\/span>Create a New User<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>It&#8217;s good for practice for creating new users and granting necessary privileges.&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-8a3078beb60dc9c5bfc8c619ced4738d\"><code><strong>CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'password';\nGRANT ALL PRIVILEGES ON example_db.* TO 'new_user'@'localhost';\nFLUSH PRIVILEGES;<\/strong><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Exit_MySQL\"><\/span>Exit MySQL<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Once you&#8217;re done, exit the MySQL shell.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-d79ac1ed6e96424e392fcc2464ab0d58\"><code><strong>EXIT;<\/strong><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Final_Thought_on_Install_MySQL_on_Ubuntu\"><\/span>Final Thought on Install MySQL on Ubuntu<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Following these steps will give you a fully functional <a href=\"https:\/\/www.mysql.com\/\" target=\"_blank\" rel=\"noopener\">MySQL<\/a> server on your Ubuntu! Now you can easily create a database, users, and tables for developing websites and applications running a production server.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When it comes to installing MySQL on Ubuntu for relational database management systems is a crucial step in setting up a web application stack. This guide will walk you through the process of how to install MySQL on Ubuntu. Prerequisites to Install MySQL on Ubuntu 24 Remember that before installing any components, such as Linux, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":2520,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[402],"tags":[407,406,408],"class_list":["post-2496","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-lamp-stack","tag-install-mysql","tag-install-mysql-on-ubuntu","tag-mysql-database"],"_links":{"self":[{"href":"https:\/\/www.hostbet.in\/blog\/wp-json\/wp\/v2\/posts\/2496"}],"collection":[{"href":"https:\/\/www.hostbet.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostbet.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostbet.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostbet.in\/blog\/wp-json\/wp\/v2\/comments?post=2496"}],"version-history":[{"count":30,"href":"https:\/\/www.hostbet.in\/blog\/wp-json\/wp\/v2\/posts\/2496\/revisions"}],"predecessor-version":[{"id":2670,"href":"https:\/\/www.hostbet.in\/blog\/wp-json\/wp\/v2\/posts\/2496\/revisions\/2670"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostbet.in\/blog\/wp-json\/wp\/v2\/media\/2520"}],"wp:attachment":[{"href":"https:\/\/www.hostbet.in\/blog\/wp-json\/wp\/v2\/media?parent=2496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostbet.in\/blog\/wp-json\/wp\/v2\/categories?post=2496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostbet.in\/blog\/wp-json\/wp\/v2\/tags?post=2496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}