Offline Install MySQL on CentOS
Install
Recently this problem came across to me: I have to install MySQL Server on a Server (CentOS) with access only to LAN where yum is useless.
Here is the solution I found useful:
Step 1. Download MySQL
Download the package you desire from here as follows..

Step 2. Remove the built-in mariaDB
- query the installed packages
rpm -qa | grep -i mariadb
This should print some names.
- remove them
rpm -e --nodeps <package_names_listed_above>
Replace <package_names_listed_above> with the names shown with the previous command.
Step 3. Create a New User for MySQL Management (Optional)
- Create new accounts/ account groups
1 | |
- Create directories for data/log/etc.
The directories shall be consistant with what you configure in my.cnf, which will be created later.
1 | |
Step 4. Upload the software to the server
Move the software to /usr/local, create symbolic link and enable only usr mysql with the access.
1 | |
Step 5. Create a config file my.cnf
1 | |
A complete example (also what I am using) of my.cnf will be provided at the end of this blog.
Step 6. Install MySQL
1 | |
After this step, a randomly initialized password for root user will be generated in home/mysql/3306/log/error.log,
or the directory you specify at my.cnf
Step 7. Setup auto-start service
1 | |
Step 8. Configure environment variables
1 | |
Step 9. Login and reset password
1 | |
Upgrade/uninstall
A method is also provided if you wanna upgrade or unintall the mysql that was installed in this way. Please backup import files before you go.
Step 1. Delete related service
1 | |
Step 2. Empty related directories
1 | |
Step 3. Remove installed software
1 | |
An example for my.cnf
1 | |