Installing MySQL on Ubuntu
1 CommentLast Updated on October 21, 2024 by jt
MySQL is the most popular open-source database management system. MySQL uses a relational database and Structured Query Language (SQL) to manage its data.
In this post, I’ll show you how to install MySQL on Ubuntu.
Installing MySQL
There are two ways to install MySQL on Ubuntu. First is to use one of the versions included in the APT package repository by default. Use the following command to find the MySQL version in the APT package repository.
apt search mysql
To install MySQL included in the APT repository:
- Update the package index on your server
sudo apt-get update
- Install the package
sudo apt-get install mysql-server-5.6
During installation, the installer will prompt you to create a root password. Type a secure one and ensure you remember it.
Note: If you are not sure about the version, you can omit the version and run sudo apt-get install mysql-server
. This installs the latest version for your Linux distribution.
Installing a Newer MySQL Vwersion
If you want to install the latest MySQL version, such as MySQL 5.7 you’ll need to manually add the MySQL’s repository first. To do so, perform the following steps:
- Install the newer APT package repository from the MySQL APT repository page.
wget http://dev.mysql.com/get/mysql-apt-config_0.6.0-1_all.deb
- Go through the prompt to select and apply the specific MySQL version to install.
- Update the package index on your server.
sudo apt-get update
- Install the package.
sudo apt-get install mysql-server
Once installation is complete, MySQL should run automatically. You can check the status of MySQL using the following command.
service mysql status
In order to stop MySQL from the running state, run the following command:
sudo service mysql stop
To start MySQL, run the following command:
sudo service mysql start
Refer to the official documentation here for various post-installation setup and configurations of MySQL.
rutvik
Thanks for the resource !