CentOS 7.9 环境下部署 MySQL 5.7 服务

sudo setenforce Permissive

sudo vi /etc/selinux/config
  SELINUX=permissive

sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service

sudo su -
echo -e '[mysql57-community]\nname=MySQL 5.7 Community Server\nbaseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/\nenabled=1\ngpgcheck=0\ngpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql\n' > /etc/yum.repos.d/mysql-community.repo
exit

sudo yum install -y mysql-community-server

sudo mkdir -p /opt/var/lib/mysql/
sudo chown mysql:mysql /opt/var/lib/mysql/
sudo chmod o-r /opt/var/lib/mysql/

sudo mkdir /opt/var/log/

sudo touch /opt/var/log/mysqld.log
sudo chown mysql:mysql /opt/var/log/mysqld.log
sudo chmod o-r /opt/var/log/mysqld.log

sudo vi /etc/my.cnf
  [mysql]
  socket=/opt/var/lib/mysql/mysql.sock

  [mysqld]
  datadir=/opt/var/lib/mysql
  socket=/opt/var/lib/mysql/mysql.sock
  log-error=/opt/var/log/mysqld.log
  pid-file=/run/mysqld/mysqld.pid

  character-set-server=utf8mb4
  collation-server=utf8mb4_unicode_520_ci    # MySQL 8.0 utf8mb4_0900_ai_ci

sudo systemctl enable mysqld.service
sudo systemctl start mysqld.service

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

mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY '********';
quit

mysql -u root -p
CREATE USER 'vbird'@'%' IDENTIFIED BY '********';
GRANT PROCESS ON *.* TO 'vbird'@'%';
CREATE DATABASE db_vbird;
GRANT ALL ON db_vbird.* TO 'vbird'@'%';
quit

posted @ 2021-04-02 17:41  f0rsaken  阅读(129)  评论(0编辑  收藏  举报