centos7 安装mysql8.0.28
2022/6/28 2:22:46
本文主要是介绍centos7 安装mysql8.0.28,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1.下载rpm文件
https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar
2.上传到centos7中
3.解压
tar -xvf mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar -C ./mysql8
4.进入mysql8文件:
1.安装common rpm -ivh mysql-community-common-8.0.28-1.el7.x86_64.rpm --nodeps --force 2.安装 libs rpm -ivh mysql-community-libs-8.0.28-1.el7.x86_64.rpm --nodeps --force 3.安装client rpm -ivh mysql-community-client-8.0.28-1.el7.x86_64.rpm --nodeps --force 4.安装server rpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm --nodeps --force
5.对安装路径进行授权
chown mysql:mysql /var/lib/mysql -R; mkdir /var/log/mysql chown mysql:mysql /var/log/mysql -R;
6.初始化
mysqld --initialize;
7.启动报错
systemctl start mysqld.service; Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
错误信息:
2022-06-25T11:53:37.340412Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.28) initializing of server in progress as process 45584 2022-06-25T11:53:37.353199Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2022-06-25T11:53:38.176035Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2022-06-25T11:53:38.789384Z 0 [Warning] [MY-013829] [Server] Missing data directory for ICU regular expressions: /usr/lib64/mysql/private/. 2022-06-25T11:53:39.129896Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: )GK1ta/8=qqh 2022-06-25T11:54:06.619363Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.28) starting as process 45672 2022-06-25T11:54:06.677878Z 0 [Warning] [MY-010075] [Server] 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: 84256f11-f47d-11ec-8275-0050563fd5e7. mysqld: File '/var/lib/mysql/auto.cnf' not found (OS errno 13 - Permission denied) 2022-06-25T11:54:06.677969Z 0 [ERROR] [MY-010183] [Server] Failed to create file(file: '/var/lib/mysql/auto.cnf', errno 13) 2022-06-25T11:54:06.677979Z 0 [ERROR] [MY-010076] [Server] Initialization of the server's UUID failed because it could not be read from the auto.cnf file. If this is a new server, the initialization failed because it was not possible to generate a new UUID. 2022-06-25T11:54:06.678018Z 0 [ERROR] [MY-010119] [Server] Aborting 2022-06-25T11:54:06.678408Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.28) MySQL Community Server - GPL.
解决
chmod -R 777 /var/lib/mysql/auto.cnf
继续报错:
2022-06-25T12:11:48.382457Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.28) starting as process 46057 2022-06-25T12:11:48.389019Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2022-06-25T12:11:48.389071Z 1 [ERROR] [MY-012271] [InnoDB] The innodb_system data file 'ibdata1' must be writable 2022-06-25T12:11:48.389085Z 1 [ERROR] [MY-012278] [InnoDB] The innodb_system data file 'ibdata1' must be writable 2022-06-25T12:11:48.389106Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine 2022-06-25T12:11:48.389177Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed. 2022-06-25T12:11:48.389210Z 0 [ERROR] [MY-010119] [Server] Aborting 2022-06-25T12:11:48.389711Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.28) MySQL Community Server - GPL.
应该是没有权限解决办法,重写执行
chown mysql:mysql /var/lib/mysql -R;
启动
systemctl start mysqld.service;
检查状态
[root@rocketmq02 mysql8]# systemctl status mysqld.service ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2022-06-25 20:13:31 CST; 1min 12s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 46133 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 46161 (mysqld) Status: "Server is operational" Tasks: 37 CGroup: /system.slice/mysqld.service └─46161 /usr/sbin/mysqld Jun 25 20:13:28 rocketmq02 systemd[1]: Starting MySQL Server... Jun 25 20:13:31 rocketmq02 systemd[1]: Started MySQL Server.
8.修改密码:
找到初始密码:
cat /var/log/mysqld.log | grep password
执行
mysql -u root -p 进行登录
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
报错:
修改密码限制,先修改一次密码,如下:
否则你会发现,你无法修改,密码的难度的设置
显示当前设置
修改密码长度:
set global validate_password.length=4;
修改密码等级:
set global validate_password.policy=LOW;
设置chek_name
set global validate_password.check_user_name=OFF;
再次查看:
再次修改密码:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
9.设置远程访问:
create user 'root'@'%' identified with mysql_native_password by 'root'; grant all privileges on *.* to 'root'@'%' with grant option; flush privileges;
10.测试:
11.防火墙放开
sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent #重启防火墙 sudo firewall-cmd --reload
这篇关于centos7 安装mysql8.0.28的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-04部署MySQL集群项目实战:新手入门教程
- 2024-11-04如何部署MySQL集群资料:新手入门指南
- 2024-11-02MySQL集群项目实战:新手入门指南
- 2024-11-02初学者指南:部署MySQL集群资料
- 2024-11-01部署MySQL集群教程:新手入门指南
- 2024-11-01如何部署MySQL集群:新手入门教程
- 2024-11-01部署MySQL集群学习:新手入门教程
- 2024-11-01部署MySQL集群入门:新手必读指南
- 2024-10-23BinLog入门:新手必读的MySQL二进制日志指南
- 2024-10-23Binlog入门:MySQL数据库的日志管理指南