centos7安装 mysql-8.0.16

Linux(CentOS7)下rpm安装MySQL8.0.16 记录一下自己在 CentOS7 下 rpm 安装 MySQL8.0.16 的过程。 一、准备工作 1. 下载MySQL所需要的安装包 从 MySQL官网 下载,上传至 CentOS 系统 /usr/local/MySQL 目录下,当然你也可以使用 wget 命令直接下载至 CentOS,此处使用的 8.0.16 版本。 # 你想要的版本 Product Version: 8.0.16 # CentOS选择Red Hat Enterprise Linux / Oracle Linux Operating S 阅读详情

环境

CentOS Linux release 7.6.1810 (Core)

mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz

解压

[root@hadoop-2 software]# tar -vxf mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz

重命名:改什么随意,可不改

[root@hadoop-2 software]# mv mysql-8.0.16-linux-glibc2.12-x86_64 mysql8.0

进入目录,新建data文件

[root@hadoop-2 software]# cd mysql8.0/
[root@hadoop-2 mysql8.0]# mkdir data

新建my.cnf文件,加入内容

[root@hadoop-2 mysql8.0]# vim my.cnf

 文件内容


[mysqld]
port=3306
#user=mysql
socket=/tmp/mysql.sock
basedir=/opt/software/mysql8.0
datadir=/opt/software/mysql8.0/data
[client]
port=3306
socket=/tmp/mysql.sock
[mysqld_safe]
#log-error=/var/log/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid

 

初始化数据库

[root@hadoop-2 mysql8.0]# ./bin/mysqld --initialize --user=mysql --basedir=/opt/software/mysql8.0/ --datadir=/opt/software/mysql8.0/data/
2020-12-11T15:16:39.682697Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2020-12-11T15:16:39.682766Z 0 [System] [MY-013169] [Server] /opt/software/mysql8.0/bin/mysqld (mysqld 8.0.16) initializing of server in progress as process 9281
2020-12-11T15:16:53.815049Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: vapp_h_<s0R+
2020-12-11T15:16:56.389493Z 0 [System] [MY-013170] [Server] /opt/software/mysql8.0/bin/mysqld (mysqld 8.0.16) initializing of server has completed

特别注意:root@localhost: vapp_h_<s0R+

root@localhost:后面跟的是初始化密码

这边如果直接启动会报错,还有一个地方需要改的

[root@hadoop-2 etc]# vim /etc/init.d/mysql

需要把

basedir=
datadir=

--否则service mysql start 会报Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysql

 [root@hadoop-1 mysql8.0]# service mysql start
/etc/init.d/mysql: line 239: my_print_defaults: command not found
/etc/init.d/mysql: line 259: cd: /usr/local/mysql: No such file or directory
Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)

两个补充完整

#   and copy my_print_defaults to /usr/bin
# - Add the path to the mysql-installation-directory to the basedir variable
#   below.
#
# If you want to affect other MySQL variables, you should make your changes
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.

# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.

basedir=/opt/software/mysql8.0
datadir=/opt/software/mysql8.0/data

# Default value, in seconds, afterwhich the script should timeout waiting
# for server start.
# Value here is overriden by value in my.cnf.
# 0 means don't wait at all
# Negative numbers mean to wait indefinitely
service_startup_timeout=900

启动mysql服务

[root@hadoop-1 mysql8.0]# service mysql start
Starting MySQL......... SUCCESS!

登录

[root@hadoop-2 mysql8.0]# bin/mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@hadoop-2 mysql8.0]# bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.16

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>

修改登录密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
Query OK, 0 rows affected (0.00 sec)

 

配置一下环境变量方便登录

[root@hadoop-2 mysql8.0]# vim /etc/profile

#加入

export MYSQL_HOME=/opt/software/mysql8.0
export PATH=$MYSQL_HOME/bin:$PATH

[root@hadoop-2 mysql8.0]# source /etc/profile

成功......

 

问题:

1、这边稍微注意一下本来my.cnf 填的是socket=/tmp/mysql/mysql.sock

但是登录的时候一直报,所以干脆就改了,否则的话还应该创建mysql文件夹并授权的

[root@hadoop-2 mysql8.0]# bin/mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[root@hadoop-2 tmp]# mkdir mysql

[root@hadoop-2 tmp]# chmod -R 777 mysql/

2、查看读了什么地方的my.cnf,ps:有些时候可能会读的其他地方的my.cnf,导致里面的路径不正确

[root@hadoop-2 mysql8.0]# bin/mysqld --verbose --help|grep my.cnf
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
                      my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default

3、登录报错 Can't connect to local MySQL server through socket '/tmp/mysql.sock' 原因是没有启动mysql服务

[root@hadoop-2 ~]# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)
[root@hadoop-2 ~]# service mysql start
Starting MySQL SUCCESS!

可以设置开机自动启动mysql服务

[root@hadoop-1 init.d]# cp /opt/software/mysql8.0/support-files/mysql.server /etc/init.d/mysqld
[root@hadoop-1 init.d]# chmod +x /etc/init.d/mysqld
[root@hadoop-1 init.d]# chkconfig --add mysqld
[root@hadoop-1 init.d]# chkconfig --list

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off

命令说明

赋予可执行权限:chmod +x /etc/init.d/mysqld

添加为服务: chkconfig --add mysqld

查看服务列表:  chkconfig --list

看到3、4、5状态为开或者为 on 则表示成功。如果是 关或者 off 则执行一下:chkconfig --level 345 mysqld on

reboot 重启虚拟机

注意:路径要写对/etc/init.d/mysqld ,也有文章是/etc/rc.d/init.d/  我上面的是亲测没问题

远程登录:没有设置之前远程是无法登录的,设置一下就可以了

mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

 

/etc/init.d/mysql: line 239: my_print_defaults: command not found Starting MySQLCouldn‘t find MySQL 今天安装MySQL时报错。 阅读详情

相关推荐

MySQL启动错误:无法找到MySQL

确保MySQL正确安装,并且my_print_defaults命令位于系统的可执行路径中,可以确保MySQL启动脚本能够成功执行并启动MySQL数据库。确认my_print_defaults命令的位置:如果MySQL已正确安装,但是my_print_defaults命令仍然无法找到,您可以尝试手动定位该命令的位置。确保MySQL的安装目录正确,并且包含了必要的执行文件。更新系统的可执行路径:如果找到了my_print_defaults命令的位置,但它不在系统的可执行路径中,您可以将其添加到路径中。

ZaxfSass的博客 1965

MySQL启动时的两个报错问题处理和插件升级

Linux 下安装了 MySQL 初始化后,进行启动时,遇到两个错误,特地记录下来。分享给大家。具体报错如图:[root@k8s-master-02 support-fi...

weixin_40074744的博客 3719

mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz

mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz

liunx 安装 mysql 时遇到错误的解决

第一个错误 用服务的方式启动mysql后 报错 ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe) 后来的mysql的my.cfg配置文件中 发现 basedir 是已 / 结尾的 我觉得mysql要的是一个目录 而不是目录下的文件夹和文件 后来我把 末尾的 / 去掉不报错了 第二个错误 用服务的方...

qq_31683775的博客 3174

电容DAC版图布局中的对称艺术:从二维共质心到误差最小化

本文深入探讨了电容DAC版图布局中的对称艺术,重点介绍了二维共质心技术如何有效最小化误差。通过分析系统误差和随机误差的来源,详细解析了共质心布局的核心技术及优化策略,包括梯度误差补偿和寄生参数平衡方法。实战案例展示了该技术在12位SAR ADC设计中的应用效果,为高精度集成电路设计提供了重要参考。

weixin_29300241的博客 583

多任务学习中的过拟合陷阱:动态停止训练机制详解与避坑指南

本文深入剖析了多任务学习中因任务过拟合不同步导致的性能下降问题,并详细介绍了动态停止-继续训练机制。该机制通过为每个任务设置独立的训练开关,基于验证集性能动态控制其梯度更新,有效缓解了任务间负迁移,是提升多任务模型整体泛化能力的关键策略。

happy2的博客 1092

【MySQL8----安装】MySQL8.0在Linux安装

一、准备 1.首先清理环境,看是否有默认数据库 rpm -qa | grep mysql 如果有的话删除 yum remove mysql-libs-5.1.73-8.el6_8.x86_64 2.查看是否有残余文件,如果有的话清理掉 [root@wzthdev oneinstack]# find / -name mysql /var/spool/mail/mysql /dat......

Sunny 846

波士顿咨询最新发布《2025年全球支付报告:未来不稳定》:到2029 年,支付收入将预计达到 2.4 万亿美元

波士顿咨询最新发布《2025年全球支付报告:未来不稳定》:到2029 年,支付收入将预计达到 2.4 万亿美元

face light~ 917

CentOS7通过tar包安装Mysql8.0.16

一、查找并卸载原有的mysql数据库 1.使用 rpm -qa | grep mysql 命令查找mysql数据库软件包及依赖包; 若没有任何显示则证明没有相关的mysql数据库; 若显示了相关的软件包及依赖包,使用yum remove xxx 命令依次删除显示的包;注意:xxx为显示的软件包及依赖包包名; 2.使用find / -name mysql 命令查找原有mysql数据库的相...

JJ-X的博客 1万+

windows11 远程桌面连接 通过代理连接RDP桌面报错 错误代码0x904 拓展错误代码0x7

打开windows Defender防火墙设置--允许应用通过防火墙更改设置--允许其他应用浏览--进入C:\WINDOWS\system32目录选择mstsc.exe进入C:\Windows\SysWOW64目录h'qmstsc.exe添加后列表里多了一个远程桌面连接,还有一个Remote Desktop Connection,配置网络权限后保存连接成功。

weixin_43978891的博客 1万+

合肥工业大学嵌入式系统原理实验报告

GPKDAT 的6、7引脚设置低电平,设置GPKDAT = 0x30则34灯亮12灯灭,GPKDAT 的4、5、6、7引脚全为高电平,设置GPKDAT = 0xf0,则led灯全灭。注意在烧写时要连接主机后面的USB接口,烧写完成后,要关闭开发板电源,将S2拨动开关置于NAND位置,然后重新开启开发板电源, 则开发板运行刚刚烧入的裸机程序。实验修改要求:在延时不变的条件下,将原程序中四个LED全亮,然后全灭的显示状态,修改为“四个全亮,然后1和2亮(3和4灭),然后3和4亮(1和2灭),最后全灭”。

Martin-share的博客 3098

Liunx CentOS7 安装mysql8.0.16

Liunx CentOS7 安装mysql8.0.16 如果之前安装过需要卸载mysql 1.下载mysql 之前在Liunx中使用在线下载,结果失败了。出了一些问题。 选择使用windows下载好,再传进去 可以去官网下载 https://pan.baidu.com/s/14HgGAiW17T6ky_YABj24CQ 提取码:9gfg 这里我放在网盘,可以直接下载 2.导入Liunx 1).创...

ReverieZH的博客 603

FCTA/FCTB 前方交通穿行预警/制动系统技术规范

FCTA&FCTB前方交叉路口预警制动系统是针对十字路口和停车场等"鬼探头"场景设计的驾驶辅助系统。系统在自车速度0-40km/h范围内工作,通过角雷达和摄像头检测侧向来车.

未知艺术家的博客 743

centos 7源码安装mysql8.0,Centos 7 编译安装MySql 8.0.16

之前有一篇 Centos 7 编译安装MySql 8.0.11的文章,最近MySql发布了8.0.16,发现编译安装跟之前不太一样,所以记录一下,闲话少叙,开整。其中对于GCC的版本要求从 4.8 提升到了 5.3+ ,并且弃用cmake改用cmake3,所以编译安装第一步就是升级GCC的版本和安装cmake31、安装gcc 8.2 及cmake3# yum install epel-releas...

weixin_27960253的博客 190

NXOpenC#-通用NX对象操作Tag,Handle,TaggedObject介绍

NXOpenC#-通用NX对象操作Tag,Handle,TaggedObject介绍

阿飞2018 1184

YOLOv11【第一章:零基础入门篇·第10节】YOLOv11项目实战:从零搭建检测系统!

🏆 本文收录于专栏 《YOLOv11实战:从入门到深度优化》。本专栏围绕 YOLOv11 的改进、训练、部署与工程优化 展开,系统梳理并复现当前主流的 YOLOv11 实战案例与优化方案,内容目前已覆盖 分类、检测、分割、追踪、关键点、OBB 检测 等多个方向。

**My Coding Family** 5770

centOS7.6下安装mysql8.0.16

centOS7.6下安装mysql8.0.16 直接在centos中下载安装包,无需本地下载在传输过去 rpm -qa | grep mariadb # 查看是否安装mariadb包 rpm -e XXXXXX --nodeps # 通过该命令卸载mariadb包 在/usr/local 下建立mysql文件夹 cd /usr/loca...

richer__的博客 259

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

mysql7.0.16_【mysql】centos7下安装mysql8.0.16(rpm方式)

一、下载地址:https://downloads.mysql.com/archives/community/选择如下:二、安装将下载后的rpm包上传到虚拟机/服务器上,我这里是放在了/usr/local/mysql/下,如果没有mysql文件夹新建一个即可。1. 解压.tar文件tar -xf mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar2. 开始安装如下四个r...

weixin_42117150的博客 190

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

Centos 7.6 下Mysql8.0.16编译安装

Centos 7.6 下Mysql8.0.16编译安装 1.最小化安装系统 2.安装基础包 yum-yinstallntpdategccgcc-c++...

cuanshao4773的博客 491

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

centos7.6arm安装mysql8.0.17_CentOS 7.6 下MySQL 8.0.16编译安装

1.最小化安装CentOS 7.6系统2.安装基础包yum -y install ntpdate gcc gcc-c++ ncurses ncurses-devel cmake readline-devel zlib.x86_64 zlib-devel.x86_64 bison libcurl-* net-tool* tree nmap sysstat lrzsz dos2unix telnet....

weixin_42509894的博客 220

centos7安装MySQL8.0.16

我常常因为环境问题,影响开发进度。就像这次我因为在centos7安装mysql耽搁了好久,我刚开始安装的是5.7版本,装完后,起不来,翻阅网上各种解决方案,都解决不了问题。无奈,我打算重装,换个高版本(MySQL8.0.16),结果MySQL8.0.16和之前的版本有少许差异,也是折腾了我好些时间,所以,我打算把安装调试过程记录下,方便日后参阅。 第一步,清理环境 1. 首先,我们可以使用命令 ...

chrisjingu的专栏 9833

CentOS 7上安装MySQL-8.0.16

CentOS 7上安装MySQL-8.0.16 mysql8 安装https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.16-linux-glibc2.12-x86_64.tar 1.卸载mariadb[root@node2 ~]# rpm -qa|grep mariadbmariadb-libs-5.5.60-1.el7_5.x86_...

weixin_30663471的博客 149

cenos 在线安装mysql_centos7在线安装mysql8.0.16

一、官网复制安装源地址:1、进入官网地址:https://dev.mysql.com/downloads/repo/yum/二、进入/usr/local目录下 ,创建mysql文件夹三、使用命令“yum install wget 安装wget,接下来在线安装mysql。使用命令wget http://dev.mysql.com/get/Downloads/mysql80-community-rel...

weixin_42516600的博客 402

mysql 8.14 rpm安装_【mysql】centos7下安装mysql8.0.16(rpm方式)

一、下载地址:https://downloads.mysql.com/archives/community/选择如下:二、安装将下载后的rpm包上传到虚拟机/服务器上,我这里是放在了/usr/local/mysql/下,如果没有mysql文件夹新建一个即可。1. 解压.tar文件tar -xf mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar2. 开始安装如下四个r...

weixin_33542634的博客 142

mysql-8.0.16.tar.gz_Centos 7.6 下Mysql8.0.16编译安装

Centos 7.6 下Mysql8.0.16编译安装1.最小化安装系统2.安装基础包yum-yinstallntpdategccgcc-c++ncursesncurses-develcmakereadline-develzlib.x86_64zlib-devel.x86_64bisonlibcurl-*net-tool*treenmapsysstatlrzsz...

weixin_31430653的博客 306

centos7可以安装最新版本的mysql-8.0.16

必要的mysql组件,有4个:分别是 server、client、common、libs 按照依赖关系依次安装rpm包 依赖关系依次为:common→libs→client→server 注意:centos7能安装的mysql最高版本:mysql-8.0.16

小小白兔兔 276
上一篇: 最简单的虚拟机centos扩容
下一篇: mysql优化之前缀索引--带案例分析
zy_crazy_code
博客等级 码龄12年 290粉丝 164原创
评论 10
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值