{"id":505,"date":"2024-05-03T16:50:23","date_gmt":"2024-05-03T16:50:23","guid":{"rendered":"https:\/\/zahiralam.com\/blog\/?p=505"},"modified":"2024-08-06T12:14:51","modified_gmt":"2024-08-06T12:14:51","slug":"installing-mysql-on-ubuntu-24-04-lts-a-complete-guide","status":"publish","type":"post","link":"https:\/\/zahiralam.com\/blog\/installing-mysql-on-ubuntu-24-04-lts-a-complete-guide\/","title":{"rendered":"Installing MySQL on Ubuntu 24.04 LTS: A Complete Guide"},"content":{"rendered":"\n<p>MySQL is a robust, scalable, and widely used relational database management system (RDBMS), and it is an essential component for many software applications, especially those that rely on dynamic web content. This guide provides a step-by-step approach to installing MySQL on Ubuntu 24.04 LTS, including how to secure the installation and modify authentication settings for production environments.\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A server running Ubuntu 24.04 LTS.<\/li>\n\n\n\n<li>Sudo privileges on the server.<\/li>\n<\/ul>\n\n\n\n<p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Update Your Server<\/h3>\n\n\n\n<p>Before installing any new software, update your system\u2019s package list to ensure you have the latest information on available packages and their versions.\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-1\">sudo apt update<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20apt%20update\">\n                            <button class=\"copy-button\" data-label=\"sudo apt update\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Install MySQL Server<\/h3>\n\n\n\n<p>Install MySQL by executing the following command:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-2\">sudo apt install mysql-server<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20apt%20install%20mysql-server\">\n                            <button class=\"copy-button\" data-label=\"sudo apt install mysql-server\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>This command installs the MySQL server package and any other dependencies required.\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Check MySQL Version<\/h3>\n\n\n\n<p>Verify the installation and check the installed version of MySQL:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-3\">mysql --version<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#mysql%20--version\">\n                            <button class=\"copy-button\" data-label=\"mysql --version\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>You should see output similar to <code>mysql Ver 8.0.36-2ubuntu3 for Linux on x86_64 ((Ubuntu))<\/code>, indicating the version of MySQL installed on your system.\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Run the Security Script<\/h3>\n\n\n\n<p>After installation, run the included security script to tighten security defaults:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-4\">sudo mysql_secure_installation<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20mysql_secure_installation\">\n                            <button class=\"copy-button\" data-label=\"sudo mysql_secure_installation\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>\n\n\n\n<p>This script will guide you through some security improvements, including setting up a root password if you haven\u2019t already, removing anonymous users, disallowing remote root login, and removing the test database.\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1260\" height=\"1220\" src=\"https:\/\/zahiralam.com\/blog\/wp-content\/uploads\/2024\/05\/image.png\" alt=\"\" class=\"wp-image-506\" srcset=\"https:\/\/zahiralam.com\/blog\/wp-content\/uploads\/2024\/05\/image.png 1260w, https:\/\/zahiralam.com\/blog\/wp-content\/uploads\/2024\/05\/image-300x290.png 300w, https:\/\/zahiralam.com\/blog\/wp-content\/uploads\/2024\/05\/image-1024x991.png 1024w, https:\/\/zahiralam.com\/blog\/wp-content\/uploads\/2024\/05\/image-768x744.png 768w\" sizes=\"auto, (max-width: 1260px) 100vw, 1260px\" \/><\/figure>\n\n\n\n<p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Changing Authentication Method (Important for Production)<\/h3>\n\n\n\n<p>By default, MySQL uses the <code>auth_socket<\/code> plugin for authenticating the root user, which might not be suitable for production environments where a traditional password method is preferred. To change this:\n\n\n\n<p>1. <strong>Login to MySQL as root:<\/strong>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-5\">sudo mysql<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20mysql\">\n                            <button class=\"copy-button\" data-label=\"sudo mysql\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>2. <strong>Change the authentication method:<\/strong>\n\n\n\n<p>Replace <code>'your_new_password'<\/code> with a secure password:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-6\">ALTER USER &#039;root&#039;@&#039;localhost&#039; IDENTIFIED WITH mysql_native_password BY &#039;your_new_password&#039;;\nFLUSH PRIVILEGES;<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#ALTER%20USER%20%27root%27%40%27localhost%27%20IDENTIFIED%20WITH%20mysql_native_password%20BY%20%27your_new_password%27%3B%0AFLUSH%20PRIVILEGES%3B\">\n                            <button class=\"copy-button\" data-label=\"ALTER USER &#039;root&#039;@&#039;localhost&#039; IDENTIFIED WITH mysql_native_password BY &#039;your_new_password&#039;;\nFLUSH PRIVILEGES;\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>3. <strong>Exit MySQL:<\/strong>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-7\">exit<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#exit\">\n                            <button class=\"copy-button\" data-label=\"exit\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>4. <strong>Test the new setup:<\/strong>\n\n\n\n<p>Now, when you use:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-8\">mysql -u root -p<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#mysql%20-u%20root%20-p\">\n                            <button class=\"copy-button\" data-label=\"mysql -u root -p\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>You should be prompted to enter the password you have set, verifying that the password-based authentication is active.\n\n\n\n<h3 class=\"wp-block-heading\">Step 6: Managing MySQL Service<\/h3>\n\n\n\n<p>To control the MySQL service on your Ubuntu server:\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Start MySQL Service:<\/strong><\/li>\n<\/ul>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-9\">sudo systemctl start mysql.service<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20systemctl%20start%20mysql.service\">\n                            <button class=\"copy-button\" data-label=\"sudo systemctl start mysql.service\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Stop MySQL Service:<\/strong><\/li>\n<\/ul>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-10\">sudo systemctl stop mysql.service<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20systemctl%20stop%20mysql.service\">\n                            <button class=\"copy-button\" data-label=\"sudo systemctl stop mysql.service\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Enable MySQL to Start at Boot:<\/strong><\/li>\n<\/ul>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-11\">sudo systemctl enable mysql.service<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20systemctl%20enable%20mysql.service\">\n                            <button class=\"copy-button\" data-label=\"sudo systemctl enable mysql.service\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Disable MySQL from Starting at Boot:<\/strong><\/li>\n<\/ul>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-12\">sudo systemctl disable mysql.service<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20systemctl%20disable%20mysql.service\">\n                            <button class=\"copy-button\" data-label=\"sudo systemctl disable mysql.service\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ: Installing MySQL on Ubuntu 24.04 LTS<\/h2>\n\n\n\n<p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>How do I install MySQL on Ubuntu 24.04?<\/strong><br>To install MySQL on Ubuntu 24.04, use the command: sudo apt install mysql-server<\/li>\n\n\n\n<li><strong>What&#8217;s the process for installing MySQL server on Ubuntu 24.04?<\/strong><br>Update your system, install MySQL using apt, secure the installation, and optionally change the authentication method.<\/li>\n\n\n\n<li><strong>Is the installation process different for MySQL 8 on Ubuntu 24.04?<\/strong><br>No, the process is the same. Ubuntu 24.04 typically comes with MySQL 8.x by default.<\/li>\n\n\n\n<li><strong>How can I check the MySQL version on Ubuntu 24.04?<\/strong><br>Use the command: mysql &#8211;version<\/li>\n\n\n\n<li><strong>Can I install MySQL Workbench on Ubuntu 24.04?<\/strong><br>Yes, you can install MySQL Workbench using: sudo apt install mysql-workbench<\/li>\n\n\n\n<li><strong>Is MySQL 5.7 available for Ubuntu 24.04?<\/strong><br>MySQL 5.7 is not officially supported on Ubuntu 24.04. It&#8217;s recommended to use MySQL 8.x.<\/li>\n\n\n\n<li><strong>How do I start MySQL in Ubuntu?<\/strong><br>Use the command: sudo systemctl start mysql.service<\/li>\n\n\n\n<li><strong>What&#8217;s the command to check if MySQL is running on Ubuntu?<\/strong><br>Use: sudo systemctl status mysql.service<\/li>\n\n\n\n<li><strong>How do I secure my MySQL installation on Ubuntu?<\/strong><br>Run the security script with: sudo mysql_secure_installation<\/li>\n\n\n\n<li><strong>Can I install MySQL on Ubuntu 24 (shorthand for 24.04)?<\/strong><br>Yes, the process is the same as described for Ubuntu 24.04.<\/li>\n\n\n\n<li><strong>How do I install MySQL server on Ubuntu 24.04?<\/strong><br>The command sudo apt install mysql-server installs both the client and server.<\/li>\n\n\n\n<li><strong>What&#8217;s the process to install WordPress with MySQL on Ubuntu 24.04?<\/strong><br>Install MySQL, create a database, install PHP and Apache, then download and configure WordPress.<\/li>\n\n\n\n<li><strong>Is there an LTS version of MySQL?<\/strong><br>MySQL itself doesn&#8217;t have LTS versions, but it&#8217;s supported on Ubuntu LTS releases.<\/li>\n\n\n\n<li><strong>How do I install MySQL in Spanish? (instalar mysql en ubuntu 24.04)<\/strong><br>El proceso es el mismo: sudo apt install mysql-server<\/li>\n\n\n\n<li><strong>How can I install MySQL on Ubuntu 24 server edition?<\/strong><br>The process is identical to the desktop version: sudo apt install mysql-server<\/li>\n\n\n\n<li><strong>How do I check the MySQL version on Ubuntu?<\/strong><br>Use the command: mysql &#8211;version<\/li>\n\n\n\n<li><strong>What&#8217;s the correct way to install MySQL on Ubuntu?<\/strong><br>Update your system, use apt to install MySQL, then secure the installation.<\/li>\n\n\n\n<li><strong>How do I install MySQL Workbench on Ubuntu 24.04?<\/strong><br>Use the command: sudo apt install mysql-workbench<\/li>\n\n\n\n<li><strong>How do I start MySQL in Ubuntu after installation?<\/strong><br>Use: sudo systemctl start mysql.service<\/li>\n\n\n\n<li><strong>How do I install MySQL on Linux Ubuntu?<\/strong><br>The process is the same as described for Ubuntu 24.04 in this guide.<\/li>\n\n\n\n<li><strong>How do I run the MySQL secure installation on Ubuntu?<\/strong><br>Use the command: sudo mysql_secure_installation<\/li>\n\n\n\n<li><strong>What&#8217;s the command to install MySQL server on Ubuntu?<\/strong><br>The command is: sudo apt install mysql-server<\/li>\n\n\n\n<li><strong>How do I install MySQL on Ubuntu in French? (installer mysql ubuntu)<\/strong><br>La commande est la m\u00eame : sudo apt install mysql-server<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>With MySQL installed and secured, you are now ready to start developing applications or managing data with one of the most popular RDBMS platforms. The transition from authentication via <code>auth_socket<\/code> to <code>mysql_native_password<\/code> is particularly crucial for environments that demand traditional password security, providing you with greater flexibility and security control.\n","protected":false},"excerpt":{"rendered":"<p>MySQL is a robust, scalable, and widely used relational database management system (RDBMS), and it is an essential component for many software applications, especially those [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":843,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[214],"tags":[69,15,66],"class_list":["post-505","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software-installation","tag-mysql","tag-mysql-8","tag-ubuntu-24-04"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts\/505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/comments?post=505"}],"version-history":[{"count":4,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts\/505\/revisions"}],"predecessor-version":[{"id":896,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts\/505\/revisions\/896"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/media\/843"}],"wp:attachment":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/media?parent=505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/categories?post=505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/tags?post=505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}