部署 MySQL 服务

1 准备工作

1.1 环境信息

  • MySQL 服务器信息如下:
  1. 192.168.100.11

1.2 设置 Repo

  1. yum -y localinstall http://mirrors.ustc.edu.cn/mysql-repo/mysql57-community-release-el7.rpm

2 安装配置 MySQL

2.1 Yum 方式安装 MySQL

  1. yum install -y mysql-community-server

2.1 配置 MySQL

  1. if [ ! "$(cat /usr/bin/mysqld_pre_systemd | grep -v ^\# | grep initialize-insecure )" ]; then
  2. sed -i "s@--initialize @--initialize-insecure @g" /usr/bin/mysqld_pre_systemd
  3. fi

2.2 启动 MySQL

  1. systemctl enable mysqld
  2. systemctl start mysqld

2.3 配置数据库授权

  1. mysql -uroot
  1. Welcome to the MySQL monitor. Commands end with ; or \g.
  2. Your MySQL connection id is 2
  3. Server version: 5.7.32 MySQL Community Server (GPL)
  4. Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
  5. Oracle is a registered trademark of Oracle Corporation and/or its
  6. affiliates. Other names may be trademarks of their respective
  7. owners.
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9. mysql> create database jumpserver default charset 'utf8';
  10. Query OK, 1 row affected (0.00 sec)
  11. mysql> set global validate_password_policy=LOW;
  12. Query OK, 0 rows affected (0.00 sec)
  13. mysql> create user 'jumpserver'@'%' identified by 'KXOeyNgDeTdpeu9q';
  14. Query OK, 0 rows affected (0.00 sec)
  15. mysql> grant all on jumpserver.* to 'jumpserver'@'%';
  16. Query OK, 0 rows affected, 1 warning (0.00 sec)
  17. mysql> flush privileges;
  18. Query OK, 0 rows affected (0.00 sec)
  19. mysql> exit
  20. Bye

3 配置防火墙

  1. firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.100.0/24" port protocol="tcp" port="3306" accept"
  2. firewall-cmd --reload