- 1. 下载MySQL
- 2.查看文档
https://dev.mysql.com/doc/(官方文档)
https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html(官方安装教程)
https://blog.csdn.net/wjx_jasin/article/details/80522079
- 3. 安装依赖
root# dnf install libaio
- 4. 创建MySQL用户和组
root# groupadd mysql
root# useradd -g mysql -m mysql
- 5. 解压文件到指定文件夹
root# tar -xvf mysql-8.0.13-1.fc29.x86_64.rpm-bundle.tar -C /usr/local/mysql
- 6. 安装mysql
root# rpm -ivh mysql-community-common-8.0.13-1.fc29.x86_64.rpm
root# rpm -ivh mysql-community-libs-8.0.13-1.fc29.x86_64.rpm
root# rpm -ivh mysql-community-client-8.0.13-1.fc29.x86_64.rpm
root# rpm -ivh mysql-community-server-8.0.13-1.fc29.x86_64.rpm
- 6.1 遇到报错
error: Failed dependencies:
libmecab.so.2()(64bit) is needed by mysql-community-server-8.0.13-1.fc29.x86_64
解决:下载 dnf install mecab.x86_64[/usr/lib/tmpfiles.d/mdadm.conf:1] Line references path below legacy directory /var/run/, updating /var/run/mdadm → /run/mdadm; please update the tmpfiles.d/ drop-in file accordingly.
[/usr/lib/tmpfiles.d/mysql.conf:23] Line references path below legacy directory /var/run/, updating /var/run/mysqld → /run/mysqld; please update the tmpfiles.d/ drop-in file accordingly.
[/usr/lib/tmpfiles.d/samba.conf:1] Line references path below legacy directory /var/run/, updating /var/run/samba → /run/samba; please update the tmpfiles.d/ drop-in file accordingly.
解决:将文件中的目录该为提示中的目录
- 7. 初始化MySQL
root# mysqld --initialize --user=mysql
- 8. 查看MySQL密码
[root@Fedora-Server run]# cat /var/log/mysqld.log
2018-11-26T03:01:33.391812Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.13) initializing of server in progress as process 2399
2018-11-26T03:01:46.392883Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Vpia7>,oegR9
2018-11-26T03:01:57.432035Z 0 [System] [MY-013170] [Server] /usr/sbin/mysqld (mysqld 8.0.13) initializing of server has completed
- 9. 启动MySQL
root# systemctl start mysqld.service
- 10 登录MySQL
root# mysql -u root -p
// 输入刚才的随机密码
alter user 'root'@'localhost' identified by '123456'; // 修改密码
/*
开启MySQL远程登录
*/
show databases;
use mysql;
GRANT ALL ON *.* TO 'root'@'%';
- 11. 加入防火墙
Fedora使用的是firewall(动态防火墙)不了解可以去查一下
1.查看当前使用防火墙激活的域
root# firewall-cmd --list-all
FedoraServer (active)
target: default
icmp-block-inversion: no
interfaces: eno1
sources:
services: cockpit dhcpv6-client ssh
ports: 1521/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
2. 将3306端口加入防火墙允许的通过端口里
// --zone=FedoraServer 一定要写已经激活的域,不然没用
root# firewall-cmd --zone=FedoraServer --add-port=3306/tcp --permanent
3. 更新防火墙
root# firewall-cmd --reload
12. 连接MySQL