文档课题:MySQL 5.7.36安装
系统:rhel 7.9 64位
安装包:mysql-5.7.36-el7-x86_64.tar.gz
1、安装
1.1、创建目录和用户
[root@leo-mysql01 ~]# user服务器托管网add mysql
[root@leo-mysql01 ~]# echo "mysql_4U" | passwd mysql --stdin
[root@leo-mysql01 ~]# mkdir -p /mysql/data
[root@leo-mysql01 ~]# mkdir -p /mysql/binlog
[root@leo-mysql01 ~]# mkdir -p /opt/mysql
[root@leo-mysql01 ~]# mkdir -p /opt/logs
[root@leo-mysql01 ~]# chown -R mysql:mysql /mysql/
[root@leo-mysql01 ~]# chown -R mysql:mysql /opt
[root@leo-mysql01 ~]# su - mysql
[mysql@leo-mysql01 ~]$ mkdir etc
1.2、关闭防火墙
[root@leo-mysql01 ~]# systemctl stop firewalld
[root@leo-mysql01 ~]# systemctl disable firewalld
1.3、文件处理
sftp> lcd F:installmediummysqlMySQL-5.7.36
sftp> cd /opt
sftp> put mysql-5.7.36-el7-x86_64.tar.gz
[root@leo-mysql01 ~]# cd /opt
[root@leo-mysql01 opt]# chown mysql:mysql mysql-5.7.36-el7-x86_64.tar.gz
[root@leo-mysql01 opt]# su - mysql
[mysql@leo-mysql01 ~]$ cd /opt
[mysql@leo-mysql01 opt]$ tar -zxf mysql-5.7.36-el7-x86_64.tar.gz
[mysql@leo-mysql01 opt]$ mv mysql-5.7.36-el7-x86_64 mysql5.7
1.4、修改配置文件
[mysql@leo-mysql01 opt]$ cd /home/mysql/etc
[mysql@leo-mysql01 etc]$ vi my.cnf
添加如下:
[mysqld]
port = 3306
basedir = /opt/mysql5.7
datadir = /mysql/data
socket = /mysql/data/mysql.sock
log-error = /opt/logs/mysql01_error.log
pid_file = /mysql/data/mysql.pid
character-set-server = utf8
slow_query_log = 1
long_query_time = 0.1
slow_query_log_file = /m服务器托管网ysql/data/mysql_slow.log
1.5、初始化数据库
[mysql@leo-mysql01 ~]$ cd /opt/mysql5.7/bin
[mysql@leo-mysql01 bin]$ ./mysqld --defaults-file=/home/mysql/etc/my.cnf --initialize-insecure --user=mysql
说明:使用--initialize-insecure参数后,告警日志中不会产生初始密码.
1.6、处理Path
[mysql@leo-mysql01 ~]$ vim .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export PATH=/opt/mysql5.7/bin:$PATH
说明:最后一行为新添加内容.
[mysql@leo-mysql01 ~]$ source .bash_profile
2、开启数据库
[mysql@leo-mysql01 ~]$ mysqld_safe --defaults-file=/home/mysql/etc/my.cnf &
[mysql@leo-mysql01 ~]$ ps -ef|grep mysql
avahi 813 1 0 13:26 ? 00:00:00 avahi-daemon: running [leo-mysql01.local]
root 58314 58071 0 14:24 pts/2 00:00:00 su - mysql
mysql 58315 58314 0 14:24 pts/2 00:00:00 -bash
root 58749 58643 0 14:47 pts/2 00:00:00 su - mysql
mysql 58750 58749 0 14:47 pts/2 00:00:00 -bash
root 58808 58597 0 14:49 pts/1 00:00:00 su - mysql
mysql 58809 58808 0 14:49 pts/1 00:00:00 -bash
root 58874 58750 0 14:50 pts/2 00:00:00 su - mysql
mysql 58880 58874 0 14:50 pts/2 00:00:00 -bash
mysql 58930 58809 0 14:51 pts/1 00:00:00 tail -500f mysql01_error.log
mysql 58935 58880 0 14:51 pts/2 00:00:00 /bin/sh /opt/mysql5.7/bin/mysqld_safe --defaults-file=/home/mysql/etc/my.cnf
mysql 59124 58935 1 14:51 pts/2 00:00:00 /opt/mysql5.7/bin/mysqld --defaults-file=/home/mysql/etc/my.cnf --basedir=/opt/mysql5.7 --datadir=/mysql/data --plugin-dir=/opt/mysql5.7/lib/plugin --log-error=/opt/logs/mysql01_error.log --pid-file=/mysql/data/mysql.pid --socket=/mysql/data/mysql.sock --port=3306
mysql 59152 58880 0 14:51 pts/2 00:00:00 ps -ef
mysql 59153 58880 0 14:51 pts/2 00:00:00 grep --color=auto mysql
3、修改密码&授予外部连接权限
[mysql@leo-mysql01 ~]$ ln -s /mysql/data/mysql.sock /tmp/mysql.sock
[mysql@leo-mysql01 ~]$ mysql -uroot -p -P 3306
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.7.36-log MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> select user,host from mysql.user;
+---------------+-----------+
| user | host |
+---------------+-----------+
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+-----------+
3 rows in set (0.00 sec)
mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'mysql_4U';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to root@'%' identified by 'mysql_4U' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
4、navicat连接mysql
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
在数字化转型的浪潮中,IT系统的稳定性、安全性和效率是企业竞争力的重要保障。然而,随着IT设备的增多、网络的复杂化、业务的多样化,IT运维面临着越来越多的挑战: 如何实现对分散在不同地点、不同网络、不同安全域的IT设备和系统的集中监控和管理? 如何实现对IT软…