The main issue here stems from package conflicts between the standard CentOS MySQL packages and third-party MySQL-server packages. The error -bash: mysql: command not found
occurs because while the server components are installed, the MySQL client package is missing.
From your rpm -qa | grep -i mysql
output, we can see:
MySQL-server-5.1.48-1.glibc23
perl-DBD-MySQL-3.0007-2.el5
php-mysql-5.1.6-27.el5_5.3
MySQL-devel-5.1.48-1.glibc23
The key missing component is the MySQL client utilities.
First, let's clean up the existing installations:
# Remove all MySQL packages completely
sudo yum remove MySQL-server MySQL-devel
sudo yum remove mysql mysql-server mysql-devel
Now install the complete MySQL stack from CentOS base repos:
# Install standard CentOS 5 MySQL packages
sudo yum --disablerepo=smartfile install mysql mysql-server mysql-devel
After installation, verify all components:
# Check installed packages
rpm -qa | grep -i mysql
# Verify mysql client is available
which mysql
mysql --version
# Check server status
sudo service mysqld status
# Secure the installation
sudo mysql_secure_installation
# Start MySQL on boot
sudo chkconfig mysqld on
# Verify service starts
sudo service mysqld restart
If mysql client is still missing, explicitly install it:
# Install just the client package
sudo yum install mysql
Or alternatively, install the MySQL client from the community repo:
# For CentOS 5
sudo yum install MySQL-client-5.1.48-1.glibc23
Important MySQL files in CentOS 5:
- Config:
/etc/my.cnf
- Error logs:
/var/log/mysqld.log
- Data directory:
/var/lib/mysql
- Sock file:
/var/lib/mysql/mysql.sock
If you specifically need MySQL 5.1 features, consider these options:
# Option 1: Install from MySQL official repos
sudo rpm -Uvh http://repo.mysql.com/mysql-community-release-el5-7.noarch.rpm
sudo yum install mysql-community-server mysql-community-client
# Option 2: Use MariaDB instead
sudo yum install mariadb mariadb-server
After installing MySQL on CentOS 5 using yum install mysql mysql-server mysql-devel
, I encountered several issues:
- The
mysqld
service couldn't be found in /etc/init.d/ - The
mysql
client binary was missing despite successful installation - Package conflicts between
mysql
andMySQL-server
packages
The key issue stems from package naming conventions in CentOS 5. The output from rpm -qa | grep -i mysql
shows:
MySQL-server-5.1.48-1.glibc23
perl-DBD-MySQL-3.0007-2.el5
php-mysql-5.1.6-27.el5_5.3
MySQL-devel-5.1.48-1.glibc23
Notice how the packages are named MySQL-server instead of mysql-server. This is because the official MySQL packages use different naming conventions than the CentOS repositories.
First, completely remove all MySQL packages:
# yum remove MySQL-server MySQL-devel
# rm -rf /var/lib/mysql
# rm -rf /etc/my.cnf
Then install using the correct package names:
# yum --disablerepo=smartfile install mysql mysql-server mysql-devel
The --disablerepo=smartfile
flag ensures we use CentOS's default repositories instead of third-party ones causing conflicts.
After installation, verify all components:
# rpm -qa | grep -i mysql
mysql-5.0.77-4.el5_6.6
mysql-server-5.0.77-4.el5_6.6
mysql-devel-5.0.77-4.el5_6.6
Start the service:
# service mysqld start
# chkconfig mysqld on
If the mysql
command still isn't available, explicitly install the client:
# yum install mysql-client
Or locate the binary manually:
# find / -name mysql -type f 2>/dev/null
/usr/bin/mysql
Add it to your PATH if necessary:
export PATH=$PATH:/usr/bin
If the package conflicts persist, consider manual installation:
1. Download the RPMs from MySQL's site:
wget https://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-server-5.1.73-1.glibc23.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-client-5.1.73-1.glibc23.x86_64.rpm
2. Install them:
rpm -ivh MySQL-server-5.1.73-1.glibc23.x86_64.rpm
rpm -ivh MySQL-client-5.1.73-1.glibc23.x86_64.rpm
3. Initialize the database:
mysql_install_db
chown -R mysql:mysql /var/lib/mysql