We have many ways to install MySQL on linux machines such as source, binary and so on. But most of the Engineers always prefer default package managers (yum for RPM-Based distributions and apt for DPKG-Based distributions) for its ease of use and it can resolve all dependencies on its own. And of course, it is not possible to use package managers in environments where the internet is not allowed, but this is a different case.
At some point, we need to install exactly specific version of MySQL for the following cases
- To create Production Replicas
- To simulate an Production Issue on similar kind of environment
- To configure Disaster Recovery(DR)/UAT Setup
- Compatibility with opensource tools ( Eg , Xtrabackup compatibility )
But following the instructions from MySQL Documentation for installation using yum always leads to the installation of the latest version released. At the time of writing this blog, the latest release is MySQL 8.0.22. Following the documentation steps resulted in installation of the same. Definitely, we can install other versions of MySQL using RPM files. But it is quite tough at times because of its dependencies or conflicts with any other older version packages.
So, in this blog post, we will look at how to install a specific version of MySQL using yum. All the following steps are tested in CentOS 7 and it requires sudo privileges.
- Setting up Yum Repository
The below command will enable the yum repository required for the installation of MySQL
- Disabling all repos in MySQL
It is to disable repos for all versions of MySQL.
- To install MySQL 8 of particular minor version, let’s say 8.0.20 , we can execute the following command
So, the general command will be like
Where X is the minor version that you want
Or else if you want to install the latest version, just go with the below command. It will install the latest version available at that time.
That’s it if the above command succeeds. We will get the required version successfully installed on the server.
- Start the MySQL service
Use the below service command to start up the MySQL service
- Get the temporary password in the error log
By default, MySQL will generate a temporary password for root user and it will be in the error log. So, to get the temporary password from error log use the below command.
The sample output would be like:
- Login the MySQL using root user with the temporary password
- On successful login, we should reset the root user password as the first thing. Otherwise, we cannot execute any commands until we reset the password. we will get the warning like below
To reset the root user password, execute the below query on mysql prompt.
Sample query be like
Once it is done, our MySQL setup is ready to use. For fine tuning of MySQL to handle production work load, refer our presentation Fine Tuning of MySQL 8.0 which was taken at Mydbops Database Meetup.
Also, look our other blogs that explores the coolest features of MySQL 8.0 which greatly helps for Database Administrators and Developers.
Need help with MySQL installations, optimization, or other database challenges? Contact Mydbops today for expert guidance!
{{cta}}