linux环境下的安装
准备
系统 :CentOS-7-x86_64-DVD-1810.iso 数据库版本:mysql-5.7.26
清理历史环境
_01 ~]# rpm -qa | grep mariadb mariadb-libs-5.5.60-1.el7_5.x86_64 [_01 ~]# yum remove mariadb-libs -y
创建用户和组
[_01 ~]# useradd mysql -s /sbin/nologin [_01 ~]# id mysql uid=1000(mysql) gid=1000(mysql) groups=1000(mysql)
创建相关目录
# 创建软件目录 mkdir -p /app/database/ # 创建数据目录 mkdir -p /data/3306 # 创建日志目录 mkdir -p /binlog/3306
设置权限
chown -R mysql.mysql /app/ /data/ /binlog/
上传软件并解压做软链接
[_01 ~]# cd /app/database/ [_01 database]# ls mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz [_01 database]# tar xf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz [_01 database]# ll total 629756 drwxr-xr-x 9 root root 129 Apr 29 13:50 mysql-5.7.26-linux-glibc2.12-x86_64 -rw-r--r-- 1 root root 644869837 Apr 29 13:49 mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz [_01 database]# ln -s mysql-5.7.26-linux-glibc2.12-x86_64 mysql [_01 database]# ll total 629756 lrwxrwxrwx 1 root root 35 Apr 29 13:51 mysql -> mysql-5.7.26-linux-glibc2.12-x86_64 drwxr-xr-x 9 root root 129 Apr 29 13:50 mysql-5.7.26-linux-glibc2.12-x86_64 -rw-r--r-- 1 root root 644869837 Apr 29 13:49 mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz [_01 database]# cd mysql [_01 mysql]# ll total 36 drwxr-xr-x 2 mysql mysql 4096 Apr 29 13:50 bin -rw-r--r-- 1 mysql mysql 17987 Apr 13 2019 COPYING drwxr-xr-x 2 mysql mysql 55 Apr 29 13:50 docs drwxr-xr-x 3 mysql mysql 4096 Apr 29 13:50 include drwxr-xr-x 5 mysql mysql 230 Apr 29 13:50 lib drwxr-xr-x 4 mysql mysql 30 Apr 29 13:50 man -rw-r--r-- 1 mysql mysql 2478 Apr 13 2019 README drwxr-xr-x 28 mysql mysql 4096 Apr 29 13:50 share drwxr-xr-x 2 mysql mysql 90 Apr 29 13:50 support-files
设置环境变量
vim /etc/profile # 添加一行 export PATH=/app/database/mysql/bin:$PATH # 生效配置 source /etc/profile # 使用mysql -V打印出数据库版本说明环境变量配置成功 [_01 mysql]# mysql -V mysql Ver 14.14 Distrib 5.7.26, for linux-glibc2.12 (x86_64) using EditLine wrapper
初始化系统库表
[_01 mysql]# mysqld --initialize-insecure --user=mysql --basedir=/app/database/mysql --datadir=/data/3306/ # 报错 mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory # 解决 [_01 mysql]# yum install -y libaio-devel # 再次运行 [_01 mysql]# mysqld --initialize-insecure --user=mysql --basedir=/app/database/mysql --datadir=/data/3306/
5.7 初始化方式
mysqld --initialize
- 初始化完成后,会生成12位临时密码,但是必须在使用mysql之前重置这个密码
- 密码管理使用严格模式(密码复杂度、长度)
mysqld --initialize-insecure
- 可以直接使用 mysql 访问,无需密码
5.6 初始化方式
/app/database/mysql/scripts/mysql_install_db --user=mysql --basedir=/app/database/mysql --datadir=/data/3306/
配置文件设置
cat >/etc/my.cnf <<EOF [mysqld] user=mysql basedir=/app/database/mysql datadir=/data/3306/ server_id=6 port=3306 socket=/tmp/mysql.sock [mysql] socket=/tmp/mysql.sock EOF
准备 MySQL 启动脚本
[_01 app]# cd /app/database/mysql/support-files # 拷贝MySQL启动脚本至系统软件管理目录中 [_01 support-files]# cp mysql.server /etc/init.d/mysqld
# centos 6 [_01 ~]# service mysqld restart ERROR! MySQL server PID file could not be found! Starting MySQL.Logging to ‘/data/3306/mysql_01.err‘. SUCCESS! # centos 7 [_01 ~]# /etc/init.d/mysqld stop Shutting down MySQL.. SUCCESS! [_01 ~]# systemctl start mysqld
[_01 ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.26 MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. 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>
相关推荐
emmm00 2020-11-17
王艺强 2020-11-17
aydh 2020-11-12
世樹 2020-11-11
zry 2020-11-11
URML 2020-11-11
spurity 2020-11-10
yifangs 2020-10-13
Andrea0 2020-09-18
Ida 2020-09-16
ltd00 2020-09-12
tufeiax 2020-09-03
xjd0 2020-09-10
greatboylc 2020-09-10
adsadadaddadasda 2020-09-08
疯狂老司机 2020-09-08
CoderToy 2020-11-16
ribavnu 2020-11-16
bianruifeng 2020-11-16