Introduction
MariaDB is a popular fork of MySQL, maintained by the original MySQL developers, with the goal of preserving the freedom and openness of the open-source database. This article describes the method for installing and configuring MariaDB version 10.0 on a CentOS 6.5 64-bit system. Please note that the CentOS 6 series reached End of Life (EOL) in November 2020. It is recommended to use a newer operating system (such as CentOS 7/8 Stream, Rocky Linux, or AlmaLinux) and a newer MariaDB version (like 10.11 LTS) for production environments. The following steps are primarily for reference in learning or legacy system maintenance.
Step 1: Configure the MariaDB YUM Repository
First, create a new YUM repository configuration file.
vi /etc/yum.repos.d/MariaDB.repo
Paste the following content into the file and save it. This configuration points to the official repository for MariaDB 10.0 on CentOS 6 x86_64 systems.
# MariaDB 10.0 CentOS repository list
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Important Note: The original repository URL may no longer be valid. If you encounter connection issues, it is recommended to visit the MariaDB official download page to obtain the latest repository configuration, or consider using a newer version from the system's default repositories.
Step 2: Install MariaDB Server and Client
After configuring the repository, use the YUM package manager to install the core MariaDB packages.
sudo yum install MariaDB-server MariaDB-client
During installation, the system will prompt you to import the GPG key and confirm the installation. Press y to continue.
Step 3: Start, Stop, and Restart the MariaDB Service
In CentOS 6, you can use the traditional /etc/init.d script or the service command to manage the service.
Start the Service
sudo /etc/init.d/mysql start
Or use the more concise command:
sudo service mysql start
Stop the Service
sudo service mysql stop
Restart the Service
sudo service mysql restart
Note: In MariaDB, the service name is typically mysql, consistent with MySQL.
Enable Automatic Startup on Boot
To ensure MariaDB starts automatically after a system reboot, execute:
sudo chkconfig mysql on
Step 4: Security Initialization (Recommended)
After installation, it is strongly recommended to run the security configuration script to set the root password, remove anonymous users, disable remote root login, etc.
sudo mysql_secure_installation
Follow the prompts to complete a series of security settings.
Step 5: Uninstall MariaDB
If you need to uninstall the MariaDB server package, use the following command:
sudo yum remove MariaDB-server
This command removes the server package but typically does not automatically delete configuration files (e.g., /etc/my.cnf) and the data directory (e.g., /var/lib/mysql). To completely remove them, manually delete these residual files and directories.
Summary and Update Recommendations
This article demonstrates the process of installing the older MariaDB 10.0 on the unsupported CentOS 6.5. For new projects, we strongly recommend:
- Use a supported operating system, such as CentOS 7 (EOL June 2024), CentOS Stream, Rocky Linux, or Ubuntu LTS.
- Install a Long-Term Support (LTS) version of MariaDB, such as the 10.11 or 11.x series, to receive security updates and new features.
- Use the system's default repositories or the latest repository configuration provided by MariaDB for installation.
By following these recommendations, you can ensure the security and stability of your database environment.