Compile and install MySQL 5.6.14 tutorial under CentOS 6.4
- 2021-06-28 14:24:33
- OfStack
Summary:
MySQL installed via yum under CentOS 6.4 is version 5.1 and older, so you want to install a higher version of 5.6.14 from source code.
Text:
1. Uninstall old versions
Use the following command to check if MySQL Server is installed
rpm -qa | grep mysql
If so, uninstall it by following the command
rpm -e mysql // Normal Delete Mode
rpm -e --nodeps mysql
// Force Delete mode, if deleted using the command above,
Prompt for other files that depend on it, then use this command to delete them forcefully
2. Install MySQL
Install packages needed to compile code
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
Download MySQL 5.6.14
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.14.tar.gz
tar xvf mysql-5.6.14.tar.gz
cd mysql-5.6.14
Compile Installation
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install
Compiled parameters can be referred to http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html.
The whole process takes about 30 minutes...a long wait
3. Configure MySQL
Set permissions
Use the following command to see if there are mysql users and user groups
cat /etc/passwd View User List
cat /etc/group View list of user groups
Create if not
groupadd mysql
useradd -g mysql mysql
Modify/usr/local/mysql permissions
chown -R mysql:mysql /usr/local/mysql
Modify/usr/local/mysql permissions
Initialize Configuration
Enter Installation Path
cd /usr/local/mysql
Enter the installation path, execute the initialization configuration script, create the system's own database and tables
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
Note: When starting the MySQL service, my.cnf will be searched in one order, first in the / etc directory, then'$basedir/my.cnf'will be searched if it is not found, in this case / usr/local/mysql/my.cnf, which is the default location for the new version of MySQL configuration file!
Note: After the minimum installation of the CentOS version 6.4 operating system, there will be an my.cnf in the / etc directory. You need to rename this file to another name, such as: /etc/my.cnf.bak. Otherwise, this file will interfere with the correct configuration of the MySQL installed by the source code and cause it to fail to start.
After updating the system with "yum update", you need to check if there is one more my.cnf in the / etc directory and rename it to something else.Otherwise, MySQL will start using this profile, which may cause problems such as not starting properly.
Start MySQL
Add the service, copy the service script to the init.d directory, and set the startup
cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start -- start-up MySQL
Configure Users
When MySQL starts successfully, root does not have a password by default. We need to set the root password.
Before setting up, we need to set up PATH, or we can't call mysql directly
Modify/etc/profile file to add at the end of the file
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
0
Close the file and run the following command for the configuration to take effect immediately
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
1
Now, we can enter mysql directly into the terminal, mysql's environment
Perform the following command to modify the root password
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
2
To set up remote access for root users, execute
mysql
>
GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.16.%' IDENTIFIED BY 'password' WITH GRANT OPTION;
When the red password is remote access, the password of the root user can be different from the local password.
Configure Firewall
Firewall port 3306 is not open by default. To access it remotely, you need to open this port
Open/etc/sysconfig/iptables
Under "-A INPUT m state state NEW m tcp p dport 22 j ACCEPT", add:
-A INPUT -m state --state NEW -m tcp -p -dport 3306 -j ACCEPT
Then save and close the file, run the following command inside the terminal to refresh the firewall configuration:
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
4
OK, 1 Once everything is configured, you can visit your MySQL~
Add on December 02, 2014:
Firewalld is used as a firewall by default in CentOS 7, so after modifying iptables, it will not work at all after restarting the system.
The following methods are used to add ports to Firewalld:
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
Exciting feature sharing: mysql different versions of installation tutorials mysql5.7 various versions of installation tutorials mysql5.6 various versions of installation tutorials