MySQ completely remove and install configuration

Remove completely

1. Review the MySQL installation which things

rpm -qa |grep -i mysql

 2. Uninstall

yum remove mysql-community-common-5.7.20-1.el7.x86_64
yum remove mysql-community-client-5.7.20-1.el7.x86_64
yum remove mysql57-community-release-el7-11.noarch
yum remove mysql-community-libs-5.7.20-1.el7.x86_64
yum removemysql-community-server-5.7.20-1.el7.x86_64
mariadb 也要删除
-qa RPM | grep MariaDB 

RPM -e - nodeps package name (for example: - nodeps MariaDB RPM -e-libs- 5.5 . 44 - 2 .el7.centos.x86_64)

3. Check whether the uninstall is complete

 4. Find the MySQL-related directory

find / -name mysql

5. Delete Related Category

rm -rf 

 6. Delete   /etc/my.cnf 

rm -rf /etc/my.cnf

7. Delete  /var/log/mysqld.log  (if you do not delete this file, it will lead to a new installation of MySQL can not generate a new password, making it impossible landing)

rm -rf /var/log/mysqld.log

installation

1. Increase official yum source (to 5.6, for example)

Create and edit mysql- community.repo file
we / etc / yum .repos.d / MySQL community.repo
The paste the following into it and save
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

Note: gpgcheck is GPG encryption check, official documents is 1, but the check will report an error, so here changed to 0 to skip the check, had no effect on the installation.

2. Install MySQL

sudo yum -y install mysql-community-server

Results are as follows:

Installed:
  mysql-community-server.x86_64 0:5.6.41-2.el7                                     

Dependency Installed:
  mysql-community-client.x86_64 0:5.6.41-2.el7                                     
  mysql-community-common.x86_64 0:5.6.41-2.el7                                     
  mysql-community-libs.x86_64 0:5.6.41-2.el7                                       
  net-tools.x86_64 0:2.0-0.22.20131004git.el7                                      
  perl-DBI.x86_64 0:1.627-4.el7                                                    
  perl-Net-Daemon.noarch 0:0.48-5.el7                                              
  perl-PlRPC.noarch 0:0.2020-14.el7                                                

Complete!

3. Start MySQL and MySQL to allow self-priming

sudo systemctl start mysqld
sudo systemctl enable mysqld

Configuration coding

1. Go to View MySQL coding

show variables like '%character%';

The results are as follows:

mysql> show variables like '%character%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

2. Modify coding

the sudo  VI / etc / the my.cnf 
# character is then added under [mysqld] -set-Server = UTF8 

the sudo  VI /etc/my.cnf.d/ client.cnf 
# default then added in [client] under -character-set = utf8

3. Again View Code:

mysql> show variables like '%character%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

 

Guess you like

Origin www.cnblogs.com/inmoonlight/p/11904263.html