Installing MySQL with APT on Linux Ubuntu Systems. How to install MySQL on Ubuntu 15.10, Ubuntu 14.04, Ubuntu 15.04 and Ubuntu 14.10. MySQL is the most popular database management system used for web and servers. Here’s how to install and use MySQL on Linux Ubuntu System.
Install MySQL on Linux Ubuntu
sudo apt-get install mysql-server
The above command installs the package for the MySQL server, as well as the packages for the client and for the database common files.
During the installation, there are two requests by the dialogue boxes:
- Supply a password for the root user for your MySQL installation.
Important: Make sure you remember the root password you set. Users who want to set a password later can leave the password field blank in the dialogue box and just press OK. However, it is very important that you set the password soon using the program mysql_secure_installation, as people can gain anonymous access to your MySQL server until you have secured the database’s root account with a password. - Indicate if you want to install the test database with “Yes” or “No”. Installation of the test database is not recommended for production environments.
The password for the MySQL root user should be noted down for future reference. When installed, MySQL will bind to localhost (127.0.0.1) by default.
Using MySQL
Please note that the MySQL server is started automatically after installation. You can check the status of the MySQL server with the following command:
sudo service mysql status
OR
sudo netstat -tap | grep mysql
If MySQL Server is not running, you can type the following command to start it:
sudo service mysql restart
Other basic commands are:
To stop the MySQL server, run the following command:
sudo service mysql stop
To restart the MySQL server, use the following command:
sudo service mysql start
The MySQL client is accessed via terminal as the root user. Run the following commands to do so:
mysql -u root -p
When prompted, enter the root password you assigned during the installation.
If you need more help. You can generate a list of commands for the MySQL prompt by entering \h.
Download MySQL APT Repository
Users can also download MySQL APT Repository from official MySQL Server http://dev.mysql.com/downloads/repo/apt/ The MySQL APT repository includes the latest packages for MySQL 5.7 (GA), MySQL 5.6 (GA), MySQL Workbench 6.3 (GA) – Ubuntu Only, MySQL Router, MySQL Utilities and MySQL Connector / Python.