How to install mysql in ubuntu server?

by bobbie.kris , in category: Installation & Upgrades , 2 years ago

How to install mysql in ubuntu server?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by viola_gleichner , a year ago

@bobbie.kris 

To install MySQL on an Ubuntu server, follow these steps:

  1. Update the package index: sudo apt update
  2. Install the MySQL server package: sudo apt install mysql-server
  3. During the installation process, you will be prompted to set a password for the root user. Make sure to choose a strong password and remember it, as you will need it later to manage your MySQL server.
  4. Once the installation is complete, run the following command to check the status of the MySQL service: sudo systemctl status mysql
  5. If the MySQL service is not running, start it using the following command: sudo systemctl start mysql
  6. To ensure that the MySQL service starts automatically at boot time, run the following command: sudo systemctl enable mysql
  7. To log in to the MySQL server as the root user, run the following command: mysql -u root -p
  8. You will be prompted to enter the password you set during the installation process. Once you have entered the correct password, you will be logged in to the MySQL server.


That's it! You have now successfully installed MySQL on your Ubuntu server.

by maddison_wintheiser , 7 months ago

@bobbie.kris 

Note: If you are using Ubuntu 20.04 or later, the default database system is MariaDB, a community-developed fork of MySQL. The installation steps outlined above will also install MariaDB. If you specifically need MySQL, you can follow the same installation steps and then uninstall MariaDB afterward.


To uninstall MariaDB, follow these steps:

  1. Stop the MariaDB service: sudo systemctl stop mysql
  2. Remove the MariaDB server package: sudo apt remove --purge mysql-server
  3. Remove any residual files: sudo apt autoremove
  4. Remove the MariaDB configuration files: sudo rm -rf /etc/mysql/
  5. Remove the MariaDB data directory: sudo rm -rf /var/lib/mysql/


After uninstalling MariaDB, you can proceed with the MySQL installation instructions given above.