赞
踩
目录
1、去官网下载mysql安装包(下面是下载链接,可自行下载)
tar -zxvf /opt/mysql-5.7.43-el7-x86_64.tar.gz -C /opt
目录替换为自己的目录
# 进入mysql目录下、创建data文件夹
cd /opt/mysql-5.7.43-el7-x86_64/
mkdir data
# 初始化数据库:指定用户、指定安装目录、指定数据目录
./bin/mysqld --initialize --user=mysql --basedir=/opt/mysql-5.7.43-el7-x86_64 --datadir=/opt/mysql-5.7.43-el7-x86_64/data
注:执行尾部 “0i8!JKQg2Tne”是初始化密码,密码是随机产生的,每次都不一样。
# 给MySQL文件目录授权 -R是渗透授权
chmod -R 777 /opt/mysql-5.7.43-el7-x86_64
先修改”/etc/init.d/mysqld“
vim /etc/init.d/mysqld
[mysqld]
datadir=/opt/mysql-5.7.43-el7-x86_64/data
basedir=/opt/mysql-5.7.43-el7-x86_64
socket=/opt/mysql-5.7.43-el7-x86_64/mysql.sock
user=mysql
tmpdir=/tmp
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/opt/mysql-5.7.43-el7-x86_64/data/error.log
pid-file=/opt/mysql-5.7.43-el7-x86_64/mysql.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
配置环境变量文件 “/etc/profile”
export MYSQL_HOME=/opt/mysql-5.7.43-el7-x86_64
export PATH=$PATH:$MYSQL_HOME/bin
生效环境变量
source /etc/profile
service mysqld start
密码输入上面初始化生成的初始化密码:“0i8!JKQg2Tne”
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。