文档课题:MySQL 5.7.36安装
系统:rhel 7.9 64位
安装包:mysql-5.7.36-el7-x86_64.tar.gz
1、安装
1.1、创建目录和用户
[root@leo-mysql01 ~]# useradd 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:\installmedium\mysql\MySQL-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 = /mysql/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
MySQL 5.7.36安装
原创Liujun_Deng 博主文章分类:Mysql ©著作权
文章标签 mysql MySQL 5.7.36安装 文章分类 MySQL 数据库
-
MySQL5.7.36安装-二进制(源码)版本
MySQL5.7.36安装-二进制(源码)版本
mysql MySQL sed -
MySQL5.7.36安装-rpm版本
MySQL5.7.36安装-rpm版本
mysql MySQL ci -
MySQL5.7.36安装-docker版本
MySQL5.7.36安装-docker版本
mysql docker bc -
MySQL5.7.36安装-多实例版本
MySQL5.7.36安装-多实例版本
mysql MySQL sed