MySQL is the most popular open-source database management system supporting transactional relational databases. MySQL runs in a server-client architecture, where a MySQL server manages persistent databases and provides SQL query interfaces, while MySQL clients query the MySQL server to access MySQL databases.
In this tutorial, I will describe how to install MySQL server and client on Linux, by using a given distro's default package manager.
Install MySQL Server in Linux
To install MySQL server in Ubuntu or Debian:
During installation, you will be asked to provide the initial root password of the MySQL server. Once installation is completed, MySQL server gets started immediately, and is set to start automatically upon boot.
To install and auto-start MySQL server on boot in CentOS or RHEL:
$ sudo chkconfig mysqld on
To install and auto-start MySQL server on boot in Fedora:
$ sudo systemctl enable mysqld.service
On CentOS, Fedora or RHEL, the default installation of MySQL has no root password set, which means that anyone can log in to the root without entering any password. Thus, make sure to set the root password after installation. To set the root password, first install MySQL client (explained below), and run the following command.
$ mysqladmin -u root -p'oldpass' password 'newpass' (in case the current password is not empty)
Install MySQL Client in Linux
To install MySQL client in Ubuntu or Debian:
To install MySQL client in CentOS or RHEL:
To install MySQL client in Fedora:
Subscribe to Xmodulo
You can have daily Linux tutorials and FAQs delivered to your email inbox. Simply enter your email address below to subscribe to our mailing list. You will receive hands-on guides and carefully written tutorials related to Linux, everything for free.