First, delete the original MySQL
1. Execution of commands
1 Yum remove mysql mysql-server mysql-libs mysql-server;
2. Find the relevant file delete
1 Find/-name MySQL
Delete Folder command
1 rm-rf/user ...
3. Check if there is any MySQL software, if present, continue to delete;
1 rpm-qa|grep MySQL
Second, install MySQL
1. Download the MySQL source installation package file from the official website (https://dev.mysql.com/downloads/repo/yum/)
1 wget https://repo.mysql.com// mysql57-community-release-el6-11.noarch.rpm
2. Install the MySQL source
1 yum localinstall mysql57-community-release-el6-
3. Check if the MySQL source is installed successfully
1 " mysql.*-community.* "
See shown indicates successful installation.
You can modify vim /etc/yum.repos.d/mysql-community.repo
the source to change the MySQL version of the default installation. For example, to install version 5.6, the 5.7 source of the enabled=1 changed to Enabled=0. Then change the 5.6 source enabled=0 to Enabled=1. The effect after the change is as follows:
1 Vim/etc/yum.repos.d/mysql-community.repo
4. Install MySQL
1 Yum install Mysql-community-server
5. Start the MySQL service
1 Service mysqld start
6. Get the MySQL initial password
1 # grep ' temporary password '/var/log/mysqld.log
7. Modify the root local login password;
After the MySQL installation is complete, a default password is generated for root in the/var/log/mysqld.log file. Locate the root default password in the following way, and then log in to MySQL to modify it:
1 ' Temporary password ' /var/log/mysqld.log
8. Log in to MySQL using the password obtained in the previous step and modify the initial password
1 mysql-uroot-p' initial password ' 2'root'@' localhost' New password ';
9. Add Telnet user
By default, only the root account is allowed to log on locally, if you want to connect to MySQL on another machine, you must either modify the root to allow remote connections, or add an account that allows remote connections, for security reasons, I add a new account:
1 GRANT All Privileges on *. * to ' User name '@'%' by' password ' with GRANTOPTION;
10. Configure the default encoding to UTF8
Modifying the/ETC/MY.CNF configuration file
1 vi/etc/my.cnf
Under [Mysqld], add the encoding configuration as follows:
1 character_set_server=UTF82 init_connect='set NAMES UTF8'
Centos Uninstall MySQL Reload