MySQL5.6 source code compilation and installation of centos6 operating system

Compile and install MYSQL 5.6.26
under CENTOS6 The MySQL installed through yum under CentOS6 is version 5.1, which is relatively old, so I want to install the higher version of 5.6.26 through the source code.
1: Uninstall the old version
Use the following command to check whether MySQL Server is installed
rpm -qa | grep mysql If
yes, use the following command to uninstall
rpm -e mysql // normal delete mode
rpm -e --nodeps mysql // strong Delete mode, if you use the above command to delete, it prompts other files that depend on it, you can use this command to delete it forcefully.
2. Install the tools needed to compile MySQL
Install g++ and gdb
yum install gcc-c++
yum install gdb
install cmake
yum install cmake
install ncurses
yum install ncurses-devel
install bison
yum install bison bison-devel
3. Install MySQL
1) Refer to the following two links to download MySQL 5.6.26
http://dev.mysql.com/doc/refman/5.6/en /getting-mysql.html
http://dev.mysql.com/downloads/mirrors.html
After the download is complete, extract the
tar xvf mysql-5.6.26.tar.gz
cd mysql-5.6.26
2) Compile and install

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
- DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci

make
make install

compiled parameters please refer
to http: //dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html The
compilation process takes about 30 minutes. After compiling and installing, you can see the result
ll /usr/local/mysql
Fourth, configure MySQL
1) Configure users
Use the following command to check if there are mysql users and user groups
cat /etc/passwd Check the user list
cat /etc/group Check the user group list
If not, create it
#groupadd mysql
#useradd -r -g mysql mysql
Confirm the creation result
id mysql
Modify the permissions of the /usr/local/mysql directory
chown -R mysql:mysql /usr/local/mysql
2) Initial configuration
Install the perl required to run the MySQL test script
yum install perl
Enter the installation path
cd /usr/local/mysql
to execute the initial configuration script , create the database and tables that come with the system
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=
mysql Search my.cnf in order, first look in the /etc directory, if not found, it will search for "$basedir/my.cnf", in this case it is /usr/local/mysql/my.cnf, which is the new version of MySQL Default location for configuration files!
Note: After the minimal installation of the CentOS 6.4 operating system is completed, there will be a my.cnf in the /etc directory. This file needs to be renamed to another name, such as: /etc/my.cnf.bak, otherwise, the The file will interfere with the correct configuration of MySQL installed from source, resulting in failure to start.
After using "yum update" to update the system, you need to check whether there will be an extra my.cnf in the /etc directory. If there is more, rename it to something else. Otherwise, MySQL will use this configuration file to start, which may cause problems such as failure to start normally.
3) Start MySQL
to add services, 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 MySQL
4) Configure MySQL Account password
After MySQL is successfully started, root has no password by default. We need to set the root password.
Before setting, we need to set the PATH first, or can we directly call mysql
to modify the /etc/profile file, add
PATH=/usr/local/mysql/bin:$PATH
export PATH at the end of the file
to close the file, run the following command, let The configuration takes effect immediately
source /etc/profile
Now, we can enter mysql directly in the terminal to enter the mysql environment.
Execute the following command to modify the root password
mysql -uroot 
mysql> SET PASSWORD = PASSWORD('123456');
To set the root user to have remote access, execute
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
remote access The password can be different from the local one.
5) Configure the
firewall Port 3306 of the firewall is not enabled by default. For remote access, you need to open this port.
Open /etc/sysconfig/iptables
in "-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 in the terminal to refresh the firewall configuration:
service iptables restart
Once everything is configured, you can access MySQL.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326518012&siteId=291194637