1. Uninstall the old MySql version
1. rpm uninstall:
1> check the installation package:
Rpm-qa | grep mysql
2> normal deletion:
Rpm e mysql-5.6.16.rpm
3> force Delete. If you are prompted to have other dependent files when you use the preceding command to delete them, you can use this command to forcibly delete them.
Rpm-e -- nodeps mysql-5.6.16.rpm
2. Uninstall tar:
1> Delete temporary files:
Make clean
2> uninstall
Make uninstall
3> Delete the decompressed File
Rm-rf folder
3. Uninstall yum:
1> Uninstall a software:
Yum remove package_name
2> uninstall multiple:
Yum remove package_name1 package_name2 package_name3
Ii. Install MySql
1. Install the gcc-c ++ Compiler:
Yum-y install make gcc-c ++ cmake bison-devel ncurses-devel
2. Download and decompress the package:
1> download the tar installation package:
Wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.16.tar.gz
2> unzip the installation package:
Tar-xzvf mysql-5.6.16.tar.gz
3> rename the extracted file:
Music mysql-5.6.16 mysql
3. Compile and install:
1. Enter the installation directory:
Cd mysql
2. configuration parameters:
Cmake \
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_DATADIR =/home/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
3> compile and install:
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
3. Configure MySql:
1. Set permissions:
1> run the following command to check whether mysql users and user groups exist:
Cat/etc/passwd view User List
Cat/etc/group view User group list
2> if not, create:
Groupadd mysql
Useradd-g mysql
3> Modify/usr/local/mysql permissions:
Chown-R mysql: mysql/usr/local/mysql
2. initialize the Configuration:
1> enter the installation path
Cd/usr/local/mysql
2. Go to the installation path, execute the initialization configuration script, and create the database and table that comes with the system:
Scripts/mysql_install_db -- basedir =/usr/local/mysql -- datadir =/home/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.
3. Start MySQL:
1> Add a service, copy the service script to the init. d directory, and set it to start and take effect (optional)
Cp support-files/mysql. server/etc/init. d/mysql
Chkconfig mysql on
2> Start MySql:
Service mysql start -- start MySQL
4. 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
1> modify the/etc/profile file and add
PATH =/usr/local/mysql/bin: $ PATH
Export PATH
2> make the environment variable configuration file take effect immediately:
Source/etc/profile
3> enter mysql in the terminal to enter the mysql environment and run the following command to change the root password:
Mysql-uroot
Mysql> set password = PASSWORD ('20140901 ');
4> to set the root user to be remotely accessible, run
Mysql> grant all privileges on *. * TO 'root' @ '1970. 16.% 'identified by 'Password' with grant option;
When the red password is used for remote access, the root user password may be different from the local password.
5. configure a firewall: (this step is not required if no firewall is used)
1> port 3306 of the firewall is not enabled 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:
-A input m state -- state NEW m tcp p dport 3306 j ACCEPT
2> Save and close the file. Run the following command in the terminal to refresh the Firewall Configuration:
Service iptables restart
OK!