Article From:https://www.cnblogs.com/heqiuyong/p/9735158.html

Environment Description: centos7.5, mysql5.7

#Mariadb

# rpm -qa | grep mariadb

# rpm -e –nodeps mariadbFilename

 

 

#etc catalogue.my.cnf# rm -rf /etc/my.cnf

 

 

#/usr/local# cd /usr/local

# yum install wget

# wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

# tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

# mv mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz mysql5.7

 

 

## groupadd mysql

# useradd -g mysql mysql

 

 

## vi /etc/my.cnf

[mysqld]

user=mysql

port=3306

basedir=/usr/local/mysql5.7/

datadir=/usr/local/mysql5.7/data/

character-set-server=utf8

collation-server=utf8_bin

 

 

## mkdir -p /usr/local/mysql5.7/data/

# chown -R mysql:mysql /usr/local/mysql5.7/data/

# /usr/local/mysql5.7/bin/mysqld –initialize –user=mysql –basedir=/usr/local/mysql5.7 –datadir=/usr/local/mysql5.7/data/&

 

A temporary password is generated for root@localhost:This is the initial password of the database.

 

#mysql service, login data with the initial password, and modify the initial password.

# /usr/local/mysql5.7/support-files/mysql.server start

# /usr/local/mysql5.7/bin/mysql -u root -p

> set password=password(‘‘);

 

## vi /etc/profile

## FOR MYSQL ##

export PATH=/usr/local/mysql5.7/bin:$PATH

# source /etc/profile

 

 

## cp /usr/local/mysql5.7/support-files/mysql.server /etc/init.d/mysql

# chmod +x /etc/init.d/mysql

# chkconfig –add mysql

# chkconfig –level 35 mysql on

 

 

#> use mysql;

> update user set host = ‘%’ where user = ‘root’;

 

## service mysql stop

# service mysql start

 

#mysql3306# firewall-cmd –zone=public –add-port=3306/tcp –permanent

# firewall-cmd –reload

Well, it’s all done!

Link of this Article: Centos install MySQL

Leave a Reply

Your email address will not be published. Required fields are marked *