解压文件
tar -zvxf mysql-8.0.19-el7-x86_64.tar.gz
# 重命名后放在 /opt/software/mysql 下
mkdir data etc log
touch etc/my.ini
编辑配置文件 my.ini
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=/opt/software/mysql
# 设置mysql数据库的数据的存放目录
datadir=/opt/software/mysql/data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
# pid
pid-file=/opt/software/mysql/mysql.pid
# socket
socket=/opt/software/mysql/mysql.socket
# logerr
log-error=/opt/software/mysql/log/mysql.log
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8
初始化
bin/mysqld --initialize --datadir=/opt/software/mysql/data/
启动
nohup bin/mysqld_safe --defaults-file=/opt/software/mysql/etc/my.ini &
重置mysql-root密码
alter user ‘root‘@‘localhost‘ identified by "root";
create user root@‘%‘ identified by ‘root‘;
grant all privileges on *.* to root@‘%‘;
flush privileges;
# 创建数据库
CREATE DATABASE IF NOT EXISTS ifan
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_chinese_ci;
# 创建用户
CREATE USER ‘ifan‘@‘%‘ IDENTIFIED BY ‘ifan‘;
GRANT all privileges ON database.table TO ‘ifan‘@‘%‘;
flush privileges