MySQL 5.1 installed through yum in CentOS6.4 is old, so we can install MySQL 5.6.14 of higher version through source code. CentOS
I. uninstall the old version
Run the following command to check whether MySQL Server is installed.
Copy codeThe code is as follows:
Rpm-qa | grep mysql
If yes, run the following command to uninstall it:
Copy codeThe code is as follows:
Rpm-e mysql // normal deletion mode
Rpm-e -- nodeps mysql // strong deletion mode. if the above command is used to delete other dependent files, you can use this command to forcibly delete them.
Install MySQL
Install the package required for compiling code
Copy codeThe code is as follows:
Yum-y install make gcc-c ++ cmake bison-devel ncurses-devel
Download MySQL 5.6.14
Copy codeThe code is as follows:
Wget tar xvf mysql-5.6.14.tar.gz
Cd mysql-5.6.14
Compile and install
Copy codeThe code is as follows:
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. 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
For compilation parameters, see http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html.
The entire process takes about 30 minutes ...... Long wait
III. configure MySQL
Set permissions
Run the following command to check whether mysql users and user groups exist:
Copy codeThe code is as follows:
Cat/etc/passwd view user list
Cat/etc/group View user group list
Create if no
Copy codeThe code is as follows:
Groupadd mysql
Useradd-g mysql
Modify/usr/local/mysql permissions
Copy codeThe code is as follows:
Chown-R mysql: mysql/usr/local/mysql
Modify/usr/local/mysql permissions
Initialize configuration
Enter the installation path
Copy codeThe code is as follows:
Cd/usr/local/mysql
Go to the installation path, execute the initialization configuration script, and create the database and table that comes with the system.
Copy codeThe code is as follows:
Scripts/mysql_install_db -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data -- user = mysql
Note: When starting the MySQL service, I will be searched in certain order. cnf, which is first found in the/etc directory. If no cnf is found, "$ basedir/my. cnf ", in this example/usr/local/mysql/my. cnf, which is the default location of the new MySQL configuration file! Note: After the minimal installation of the CentOS 6.4 operating system is completed, a my. cnf, you need to rename this file to another name, such as:/etc/my. cnf. bak. Otherwise, the file will interfere with the correct configuration of MySQL installed by source code, resulting in startup failure.
Start MySQL
Add a service, copy the service script to the init. d Directory, and set startup
Copy codeThe code is as follows:
Cp support-files/mysql. server/etc/init. d/mysql
Chkconfig mysql on
Service mysql start -- start MySQL
Configure the user
After MySQL is started successfully, the root user has no password by default. we need to set the root password.
Before setting, we need to set the PATH first, or we cannot directly call mysql
Modify the/etc/profile file and add
Copy codeThe code is as follows:
PATH =/usr/local/mysql/bin: $ PATH
Export PATH
Close the file and run the following command to make the configuration take effect immediately
Copy codeThe code is as follows:
Source/etc/profile
Now, we can directly enter mysql in the terminal to enter the mysql environment.
Run the following command to change the root password:
Copy codeThe code is as follows:
Mysql-uroot
Mysql> set password = PASSWORD ('20140901 ');
To set remote access for the root user, run
Copy codeThe code is as follows:
Mysql> grant all privileges on *. *
When the red password is used for remote access, the root user password may be different from the local password.
Configure firewall
Port 3306 of the firewall is disabled by default. to access the firewall remotely, you must enable this port.
Open/etc/sysconfig/iptables
In "-a input-m state -- state NEW-m tcp-p-dport 22-j ACCEPT", add:
Copy codeThe code is as follows:
-A input m state -- state NEW m tcp p dport 3306 j ACCEPT
Save and close the file. run the following command in the terminal to refresh the firewall configuration:
Copy codeThe code is as follows:
Service iptables restart
OK. after all the configurations are complete, you can access your MySQL.