2020年8月2日 星期日

centos 7 + mysql 5.7 + /tmp/mysql.sock



## install mysql 5.7

yum update

yum install yum-utils -y

yum localinstall  https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm -y

yum-config-manager --disable mysql80-community

yum-config-manager --enable mysql57-community

yum install mysql-community-server -y


# edit  /etc/my.cnf

# 1. change socket=/tmp/mysql.sock under [mysqld] section

# add [client] section if not exist

# 2. change or add  socket=/tmp/mysql.sock under [client] section


# install selinux utils

yum install policycoreutils-python-2.5-34.el7.x86_64


# start mysql service to get fail audit log for next step

systemctl start mysqld.service  # this will not work and report error at this time


# modify selinux by analyzing audit log automatically

ausearch -c 'mysqld' --raw | audit2allow -m my-mysqld

semodule -i my-mysqld.pp


# start mysql service

systemctl start mysqld.service   # service should  start up accordingly


# get mysql temporary password in /var/log/mysqld.log

grep 'temporary password' /var/log/mysqld.log


# test mysql client connection

 mysql -p 


# change mysql root password and secure installation

mysql_secure_installation




沒有留言: