Linux rpm install MySQL

 

1 Check whether there is an older version of mysql

(1) mysql

Execute the command: rpm -qa | grep mysql, mysql if there is an old, old mysql query to delete, execute:

rpm -e --nodeps XXXX XXXX is the name of the query to mysql

 

(2) mariadb

Execute the command: rpm -qa | grep mariadb, if there is an old MariaDB, a query to delete old MariaDB, execute:

rpm -e --nodeps XXXX #XXXX query to the name of MariaDB

 

(3) find / -name mysql view residue installation file

If so, delete the command manually or

rm -rf 

 

2 closed SELINUX, to prevent the impact of mysql start (to not operate, there is a problem and then start the process of execution)

# Edit the firewall configuration file: vi / etc / selinux / config 

Disabled to modify SELINUX = enforcing

SELINUXTYPE = targeted commented

 

3 to download the corresponding installation package

Download: https://downloads.mysql.com/archives/community/ , the downloaded version is as follows:

 

4 upload the installation package to a Linux server, extract the installation

MySQL-5.6.32-1.el7.x86_64.rpm-bundle.tar

Decompression: tar xvf MySQL-5.6.32-1.el7.x86_64.rpm-bundle.tar

Installation: rpm -ivh

rpm -ivh MySQL-devel-5.6.32-1.el7.x86_64.rpm
rpm -ivh MySQL-client-5.6.32-1.el7.x86_64.rpm
rpm -ivh MySQL-server-5.6.32-1.el7.x86_64.rpm

 

5 Add Profile

cp /usr/share/mysql/my-default.cnf /etc/my.cnf

 

6 initialize the database

/usr/bin/mysql_install_db

If the following error:

FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db: Data::Dumper

You need to install autoconf: Data will be mounted when yum-y install autoconf // install this package: Dumper module

Executed again: / usr / bin / mysql_install_db

 

7 mysql user to assign directory permissions

chown -R mysql.mysql / var / lib / mysql # modify the directory file permissions

 

8 start mysql

Start mysql service mysql start #

 

9 Log modify the administrator password

Free secret login: mysql -u root

use mysql; # switch to management database

select user, host from user; # View User Information

update user set password = password ( ' abc123456') where user = root; # change the administrator password
update user set host = '%' where user = 'root' and host = '127.0.0.1'; # allows administrators to remotely log

flush privileges; # refresh permission

 

10 RPM default installation location

/ var / lib / mysql / # database directory
/ usr / share / mysql # configuration file directory
/ usr / bin # Related Commands directory
/etc/init.d/mysql # startup script

 

11 modify the character set configuration

Stop the database: service mysql stop

vim /etc/my.cnf

[mysqld]
character_set_server=utf8
character_set_client=utf8
collation-server=utf8_general_ci
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[mysql]
default-character-set = utf8

 

Start the database: service mysql start

 

Guess you like

Origin www.cnblogs.com/Latiny/p/11904340.html