MySQL 5.7二进制安装
Posted 江洋大运
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL 5.7二进制安装相关的知识,希望对你有一定的参考价值。
1.下载并上传软件至/server/tools,并解压软件
[ ]
[ ]
[ ]
rz waiting to receive.
[ ]
total 629756
-rw-r--r-- 1 root root 644869837 May 8 2020 mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
[ ]
[ ]
total 629756
drwxr-xr-x 9 root root 129 Jan 27 20:13 mysql-5.7.26-linux-glibc2.12-x86_64
-rw-r--r-- 1 root root 644869837 May 8 2020 mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
[ ]
[ ]
2.用户的创建处理原始环境
[ ]
mariadb-libs-5.5.56-2.el7.x86_64
[ ]
[ ]
3.设置环境变量
[ ]
export PATH=/application/mysql/bin:$PATH
[ ]
[ ]
mysql Ver 14.14 Distrib 5.7.26, for linux-glibc2.12 (x86_64) using EditLine wrapper
4.授权目录为 mysql 用户
[ ]
[ ]
[ ]
total 0
drwxr-xr-x 9 mysql mysql 129 Jan 27 20:13 mysql
[ ]
drwxr-xr-x 5 mysql mysql 42 Jan 27 20:09 /data/
5.初始化数据(创建系统数据)
5.6 版本 初始化命令
/application/mysql/scripts/mysql_install_db
5.7 版本初始化命令
mysqld --initialize --user=mysql --basedir=/application/mysql --datadir=/data/mysql/data
说明:--initialize 参数:
1. 对于密码复杂度进行定制:12 位,4 种
2. 密码过期时间:180
3. 给 root@localhost 用户设置临时密码
报错: mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决:[root@db01 ~]# yum install -y libaio-devel
--initialize-insecure 参数: 无限制,无临时密码
[root@web01 ~]# mysqld --initialize-insecure --user=mysql --basedir=/application/mysql --datadir=/data/mysql/data
2021-01-27T12:34:53.296796Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-01-27T12:34:53.713332Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-01-27T12:34:53.762368Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-01-27T12:34:53.819561Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 0e6e21e9-609c-11eb-9998-000c29289384.
2021-01-27T12:34:53.820405Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-01-27T12:34:53.821186Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
6.配置文件的准备
[root@web01 ~]# cat >/etc/my.cnf<<EOF
[mysqld]
user=mysql
basedir=/application/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
server_id=6
port=3306
[mysql]
socket=/tmp/mysql.sock
EOF
7.拷贝运行文件 启动数据库
service 启动
[root@web01 ~]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@web01 ~]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
[root@web01 ~]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1302/sshd
tcp6 0 0 :::3306 :::* LISTEN 3043/mysqld
tcp6 0 0 :::22 :::* LISTEN 1302/sshd
systemd 启动
[root@web01 ~]# cat >/etc/systemd/system/mysqld.service <<EOF
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/application/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
EOF
[root@web01 ~]# systemctl restart mysqld
以上是关于MySQL 5.7二进制安装的主要内容,如果未能解决你的问题,请参考以下文章
MySQLLinux下MySQL 5.55.6和5.7的RPM二进制和源码安装