Deploy MySQL on Linux: Step-by-Step Guide
The steps to deploy MySQL on Linux are as follows:
- Install MySQL.
- Install the MySQL server software package using a package manager like apt or yum.
- Download the MySQL binary files and install them according to the official documentation.
- Start the MySQL service.
- Start the MySQL service using the command systemctl start mysql.
- Alternatively, start the MySQL service using the command “service mysql start”.
- Set up MySQL.
- Execute the mysql_secure_installation command to secure configure MySQL.
- Set up a root password as per the instructions, delete anonymous users, restrict remote root login, and remove the test database.
- Login to MySQL.
- Log into MySQL using the command mysql -u username -p, then enter your password.
- Alternatively, log in as the root user using the command sudo mysql.
- Create a database and user.
- Create a database using the MySQL statement CREATE DATABASE.
- Create a user using the MySQL CREATE USER statement and assign permissions to them.
- Set up remote access for MySQL
- Edit the MySQL configuration file at /etc/mysql/mysql.conf.d/mysqld.cnf, and set the bind-address to the server’s IP address or 0.0.0.0.
- Check the firewall rules to make sure that the port for MySQL (defaulted as 3306) is accessible through the firewall.
- Restart the MySQL service
- Restart the MySQL service by utilizing the command systemctl restart mysql.
After completing the steps above, you will be able to successfully deploy and configure MySQL on Linux, and manage and operate databases.