How to Install MySQL 5.6 on CentOS 6.4 Without Compiling
A step‑by‑step guide shows how to download the binary tarball, extract it, create the mysql user, initialise the data directory, configure files, set environment variables, enable auto‑start, start the service, and secure the root account on a CentOS 6.4 system.
Step 1: Extract the tar package
Upload the downloaded mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz to /software (or any preferred directory) and run:
cd /software
tar -xzvf mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.21-linux-glibc2.5-x86_64 mysql-5.6.21Step 2: Create MySQL user and group
groupadd mysql
useradd -r -g mysql mysql
chown -R mysql:mysql mysql-5.6.21Step 3: Initialise the data directory
su mysql
cd mysql-5.6.21/scripts
./mysql_install_db --user=mysql --basedir=/software/mysql-5.6.21 --datadir=/software/mysql-5.6.21/data
exitStep 4: Configure MySQL
Copy the default configuration and init script, then edit the paths if MySQL is not installed under /software:
cd /software/mysql-5.6.21/support-files
cp my-default.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysql
# optional: edit /etc/init.d/mysql if installation directory differsModify /etc/my.cnf so that:
basedir=/software/mysql-5.6.21
datadir=/software/mysql-5.6.21/dataStep 5: Add environment variables
vim /etc/profile
export MYSQL_HOME="/software/mysql-5.6.21"
export PATH="$PATH:$MYSQL_HOME/bin"
. /etc/profileStep 6: Enable MySQL to start on boot
chkconfig --add mysql
chkconfig mysql onStep 7: Start MySQL service
service mysql startStep 8: Secure the installation
mysqladmin -u root password 'your_password' # set root password
mysql -u root -p # log in
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_password' WITH GRANT OPTION;
FLUSH PRIVILEGES;If the root account cannot log in because the user table is empty, start MySQL with --skip-grant-tables, import a valid user table, and then reset the password as shown below.
Recovering a lost root password
cd $MYSQL_HOME
./bin/mysqld_safe --basedir=/data/mysql-5.6.21 --datadir=/data/mysql-5.6.21/data --skip-grant-tables &
mysql -u root mysql
UPDATE user SET password=PASSWORD("new_password") WHERE user='root';
FLUSH PRIVILEGES;Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
