Liunx(CentOS-6-x86_64)系统安装MySql(5.6.50)

news2025/3/29 19:58:33

一:安装Liunx(CentOS-6-x86_64)

安装Liunx(CentOS-6-x86_64)

二:下载MySql(5.6.50)

MySql下载官网
在这里插入图片描述

二:安装MySql

2.1 将mysql上传到Liunx

文件地址 /usr/local/

在这里插入图片描述

2.2 解压安装MySql
cd /usr/local/
tar zxvf mysql-5.6.50-linux-glibc2.12-x86_64.tar.gz -C /usr/local

在这里插入图片描述

2.3 修改解压后包的名称(方便后续的使用)

在这里插入图片描述

2.4 配置my.cnf文件的文件
vim /etc/my.cnf

my.cnf文件内容全部替换成下面的

[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=/usr/local/mysql
# 设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql/data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为utf8mb4
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4
2.4 创建MySQL用户组
groupadd mysql
	创建MySQL用户组
useradd -r -g mysql mysql
	添加MySQL用户并添加到MySQL用户组
chown mysql:mysql -R /usr/local/mysql/data/
	赋予权限
2.5 将 MySQL 的 bin 目录添加到 PATH
export PATH=/usr/local/mysql/bin:$PATH
source ~/.bashrc
2.6 将初始化 MySQL
cd /usr/local/mysql/scripts/
./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
初始化成功的打印内容,其中打印内容中会有初始密码记得保存记录
里面的打印的初始密码
  /usr/local/mysql/bin/mysqladmin -u root password 'new-password'
  /usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Installing MySQL system tables...2025-02-21 16:51:26 0 [Warning] TIMESTAMP with implicit DEFAULT va                                                                 lue is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation fo                                                                 r more details).
2025-02-21 16:51:26 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstra                                                                 p.
2025-02-21 16:51:26 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.50) starting as process 31405                                                                  ...
2025-02-21 16:51:26 31405 [Note] InnoDB: Using atomics to ref count buffer pool pages
2025-02-21 16:51:26 31405 [Note] InnoDB: The InnoDB memory heap is disabled
2025-02-21 16:51:26 31405 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2025-02-21 16:51:26 31405 [Note] InnoDB: Memory barrier is not used
2025-02-21 16:51:26 31405 [Note] InnoDB: Compressed tables use zlib 1.2.11
2025-02-21 16:51:26 31405 [Note] InnoDB: Using Linux native AIO
2025-02-21 16:51:26 31405 [Note] InnoDB: Using CPU crc32 instructions
2025-02-21 16:51:26 31405 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2025-02-21 16:51:26 31405 [Note] InnoDB: Completed initialization of buffer pool
2025-02-21 16:51:26 31405 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a n                                                                 ew database to be created!
2025-02-21 16:51:26 31405 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2025-02-21 16:51:26 31405 [Note] InnoDB: Database physically writes the file full: wait...
2025-02-21 16:51:26 31405 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2025-02-21 16:51:26 31405 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2025-02-21 16:51:27 31405 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2025-02-21 16:51:27 31405 [Warning] InnoDB: New log files created, LSN=45781
2025-02-21 16:51:27 31405 [Note] InnoDB: Doublewrite buffer not found: creating new
2025-02-21 16:51:27 31405 [Note] InnoDB: Doublewrite buffer created
2025-02-21 16:51:27 31405 [Note] InnoDB: 128 rollback segment(s) are active.
2025-02-21 16:51:27 31405 [Warning] InnoDB: Creating foreign key constraint system tables.
2025-02-21 16:51:27 31405 [Note] InnoDB: Foreign key constraint system tables created
2025-02-21 16:51:27 31405 [Note] InnoDB: Creating tablespace and datafile system tables.
2025-02-21 16:51:27 31405 [Note] InnoDB: Tablespace and datafile system tables created.
2025-02-21 16:51:27 31405 [Note] InnoDB: Waiting for purge to start
2025-02-21 16:51:27 31405 [Note] InnoDB: 5.6.50 started; log sequence number 0
2025-02-21 16:51:27 31405 [Note] RSA private key file not found: /usr/local/mysql/data//private_key                                                                 .pem. Some authentication plugins will not work.
2025-02-21 16:51:27 31405 [Note] RSA public key file not found: /usr/local/mysql/data//public_key.p                                                                 em. Some authentication plugins will not work.
2025-02-21 16:51:27 31405 [Note] Binlog end
2025-02-21 16:51:27 31405 [Note] InnoDB: FTS optimize thread exiting.
2025-02-21 16:51:27 31405 [Note] InnoDB: Starting shutdown...
2025-02-21 16:51:29 31405 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2025-02-21 16:51:29 0 [Warning] TIMESTAMP with implicit DEFAULT value is depr                                                                 ecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more deta                                                                 ils).
2025-02-21 16:51:29 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstra                                                                 p.
2025-02-21 16:51:29 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.50) starting as process 31443                                                                  ...
2025-02-21 16:51:29 31443 [Note] InnoDB: Using atomics to ref count buffer pool pages
2025-02-21 16:51:29 31443 [Note] InnoDB: The InnoDB memory heap is disabled
2025-02-21 16:51:29 31443 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2025-02-21 16:51:29 31443 [Note] InnoDB: Memory barrier is not used
2025-02-21 16:51:29 31443 [Note] InnoDB: Compressed tables use zlib 1.2.11
2025-02-21 16:51:29 31443 [Note] InnoDB: Using Linux native AIO
2025-02-21 16:51:29 31443 [Note] InnoDB: Using CPU crc32 instructions
2025-02-21 16:51:29 31443 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2025-02-21 16:51:29 31443 [Note] InnoDB: Completed initialization of buffer pool
2025-02-21 16:51:29 31443 [Note] InnoDB: Highest supported file format is Barracuda.
2025-02-21 16:51:29 31443 [Note] InnoDB: 128 rollback segment(s) are active.
2025-02-21 16:51:29 31443 [Note] InnoDB: Waiting for purge to start
2025-02-21 16:51:29 31443 [Note] InnoDB: 5.6.50 started; log sequence number 1625977
2025-02-21 16:51:29 31443 [Note] RSA private key file not found: /usr/local/mysql/data//private_key                                                                 .pem. Some authentication plugins will not work.
2025-02-21 16:51:29 31443 [Note] RSA public key file not found: /usr/local/mysql/data//public_key.p                                                                 em. Some authentication plugins will not work.
2025-02-21 16:51:29 31443 [Note] Binlog end
2025-02-21 16:51:29 31443 [Note] InnoDB: FTS optimize thread exiting.
2025-02-21 16:51:29 31443 [Note] InnoDB: Starting shutdown...
2025-02-21 16:51:30 31443 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /usr/local/mysql/bin/mysqladmin -u root password 'new-password'
  /usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:

  /usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd . ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /usr/local/mysql/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

三:启动MySql

cd /usr/local/mysql/support-files/
./mysql.server start

启动成功的打印内容

[root@localhost scripts]# cd /usr/local/mysql/support-files/
[root@localhost support-files]# ./mysql.server start
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
. SUCCESS!
[root@localhost support-files]#

在这里插入图片描述

四:登录配置MySql

4.1:登录MySQL
cd /usr/local/mysql/bin/
./mysql -u root

在这里插入图片描述
使用sql验证一下

SELECT VERSION();

在这里插入图片描述

4.2:检查 root 用户的权限:确保 root 用户的主机是 localhost 或 %(允许远程登录)。
SELECT user, host FROM mysql.user;

其中没有%(远程登录链接的权限)
在这里插入图片描述

4.3:创建新用户并授予权限(远程链接的权限)

FLUSH PRIVILEGES; 是刷新权限

CREATE USER 'root'@'%' IDENTIFIED BY 'new-password';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

在这里插入图片描述

五:设置MySql开机自启动

复制 MySQL 提供的启动脚本到系统目录:

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

赋予脚本可执行权限:

chmod +x /etc/init.d/mysqld

添加到开机启动

chkconfig --add mysqld
chkconfig mysqld on

在这里插入图片描述

六:开启3306端口防火墙,远程链接数据库

6.1:开启3306端口防火墙

添加3306端口规则

firewall-cmd --zone=public --add-port=3306/tcp --permanent

重新加载防火墙规则

firewall-cmd --reload

验证规则是否生效,如果返回 yes,说明端口已开放

firewall-cmd --zone=public --query-port=3306/tcp

最好打印yes就是将3306端口开放了
在这里插入图片描述

6.2:远程链接数据库

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

七:报错

7.1:使用 sudo yum install 进行下载插件的错误

http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl 注意:

原因

如果报下面的报错信息是因为 没有配置仓库

解决方法

在 Liunx教程中。3.配置仓库(用于yum下载)这个节点操作一遍

报错信息

已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"


 One of the configured repositories failed (未知),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>
        or
            subscription-manager repos --disable=<repoid>

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64

7.2 ./mysql_install_db 命令报错

错误信息

FATAL ERROR: please install the following Perl modules before executing ./mysql_install_db:
Data::Dumper

解决方式 安装 autoconf
yum -y install autoconf

7.3 mysql_install_db 失败 报 Table ‘mysql.plugin’ doesn’t exist,

解决方式

重新初始化数据目录。

7.4 忘记 root 密码

停止 MySQL 服务,然后以跳过权限检查的方式启动:

mysqld_safe --skip-grant-tables &

登录 MySQL 并重置密码:

UPDATE mysql.user SET Password=PASSWORD('new_password') WHERE User='root';
FLUSH PRIVILEGES;

7.5 -bash: ./mysql_install_db: /usr/bin/perl: 坏的解释器: 没有那个文件或目录

问题原因

mysql_install_db 是一个 Perl 脚本,需要 Perl 解释器来运行。

解决方法

安装 Perl

sudo yum install perl

7.6 nslookup mirrorlist.centos.org 这个命令无法使用,显示没有这个命令

解决方法

安装 bind-utils

sudo yum install bind-utils

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2303756.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Java Web开发实战与项目——开发一个在线论坛系统

在线论坛系统是一个常见的Web应用&#xff0c;通常具有用户注册、帖子发布、评论互动、消息推送等基本功能。开发这样一个系统&#xff0c;既涉及到前后端的技术栈选择&#xff0c;也需要考虑性能、扩展性等实际问题。本文将从设计论坛模块、实现消息推送与实时更新功能、以及优…

ubuntu24.04无法安装向日葵,提示依赖libgconf-2-4怎么办?

在向日葵官方下载的deb包&#xff0c;目前是SunloginClient_15.2.0.63062_amd64.deb&#xff0c;执行安装代码&#xff0c;如下&#xff1a; sudo < /span > dpkg< /span > -i< /span > SunloginClient_15< /span >.2< /span >.0< /span >…

Kubernetes 使用 Kube-Prometheus 构建指标监控 +飞书告警

1 介绍 Prometheus Operator 为 Kubernetes 提供了对 Prometheus 机器相关监控组件的本地部署和管理方案&#xff0c;该项目的目的是为了简化和自动化基于 Prometheus 的监控栈配置&#xff0c;主要包括以下几个功能&#xff1a; Kubernetes 自定义资源&#xff1a;使用 Kube…

WPF的页面设计和实用功能实现

目录 一、TextBlock和TextBox 1. 在TextBlock中实时显示当前时间 二、ListView 1.ListView显示数据 三、ComboBox 1. ComboBox和CheckBox组合实现下拉框多选 四、Button 1. 设计Button按钮的边框为圆角&#xff0c;并对指针悬停时的颜色进行设置 一、TextBlock和TextBox…

window安装MySQL5.7

1、下载MySQL5.7.24 浏览器打开&#xff1a; https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-winx64.zip 2、解压缩 下载下来的是一个压缩包&#xff0c;解压到你想放到的目录下面&#xff0c;我放的是“C:\MySQL” 3、配置MySQL环境变量 计算机右键 - 属性 …

数据结构:哈希表(二)

目录 一、哈希表 1、概念 二、哈希冲突 1、概念 2、冲突避免 &#xff08;1&#xff09;哈希函数设计 &#xff08;2&#xff09;负载因子调节 3、冲突解决 &#xff08;1&#xff09;闭散列 1、线性探测 2、二次探测 &#xff08;2&#xff09;开散列 4、哈希桶实…

blender笔记2

一、物体贴地 物体->变换->对齐物体 ->对齐弹窗(对齐模式&#xff1a;反方&#xff0c;相对于&#xff1a;场景原点&#xff0c;对齐&#xff1a;z)。 之后可以设置原点->原点--3d游标 二、面上有阴影 在编辑模式下操作过后&#xff0c;物体面有阴影。 数据-&g…

1.21作业

1 unserialize3 当序列化字符串中属性个数大于实际属性个数时&#xff0c;不会执行反序列化 外部如果是unserialize&#xff08;&#xff09;会调用wakeup&#xff08;&#xff09;方法&#xff0c;输出“bad request”——构造url绕过wakeup 类型&#xff1a;public class&…

【Quest开发】全身跟踪(一)

软件&#xff1a;Unity 2022.3.51f1c1、vscode、Meta XR All in One SDK V72 硬件&#xff1a;Meta Quest3 最终效果&#xff1a;能像meta的操作室沉浸场景一样根据头盔移动来推断用户姿势&#xff0c;实现走路、蹲下、手势匹配等功能 需要借助UnityMovement这个包 GitHub …

最新版本Exoplayer扩展FFmpeg音频软解码保姆级教程

ExoPlayer 是一个开源的 Android 媒体播放库&#xff0c;由 Google 开发和维护&#xff0c;用于替代 Android 系统自带的 MediaPlayer。它提供了更强大的功能、更好的性能和更高的灵活性&#xff0c;适用于各种复杂的媒体播放场景。所以被广泛用于各种播放器场景。 最近项目中…

JS:页面事件

文章目录 一、页面加载事件二、页面滚动事件三、页面尺寸事件总结 一、页面加载事件 有时候我们会把script的内容放在body前&#xff0c;这时候代码的执行在元素的加载之前&#xff0c;会导致页面元素未加载而报错 解决办法是调用Window的load加载事件&#xff0c;将所有操作放…

vue,vue3 keepalive没有效果,无法缓存页面include无效,keep-alive

keepalive没有效果&#xff0c;无法缓存页面&#xff1f; 问题大概是组件的name值不对应&#xff0c;vue2修改组件文件的name值&#xff0c;vue3保持组件文件名称和路由页面配置的name一致就可以了&#xff0c;如果vue3不想保持一致&#xff0c;必须手动在文件后面添加export..…

DeepSeek智能测试知识库助手PRO版:多格式支持+性能优化

前言 测试工程师在管理测试资产时,需要面对多种文档格式、大量文件分类及知识库的构建任务。为了解决这些问题,我们升级了 DeepSeek智能测试知识库助手,不仅支持更多文档格式,还加入了 多线程并发处理 和 可扩展格式支持,大幅提升处理性能和灵活性。 主要功能亮点: 多格…

纯手工搭建整套CI/CD流水线指南

目录 一、前言 二、环境准备 1、服务器开荒&#xff08;192.168.1.200&#xff09; 2、离线资源清单&#xff08;提前用U盘拷好&#xff09; 三、硬核安装&#xff1a;比拧螺丝还细的步骤 Step1&#xff1a;搭建GitLab&#xff08;注意&#xff01;这是只内存饕餮&#xf…

智能硬件新时代,EasyRTC开启物联音视频新纪元

在万物互联的时代浪潮中&#xff0c;智能硬件正以前所未有的速度融入我们的生活&#xff0c;从智能家居的便捷控制&#xff0c;到智能穿戴设备的健康监测&#xff0c;再到工业物联网的高效管理&#xff0c;智能硬件的应用场景不断拓展。而在这个智能硬件蓬勃发展的背后&#xf…

Rust编程语言入门教程(八)所有权 Stack vs Heap

Rust 系列 &#x1f380;Rust编程语言入门教程&#xff08;一&#xff09;安装Rust&#x1f6aa; &#x1f380;Rust编程语言入门教程&#xff08;二&#xff09;hello_world&#x1f6aa; &#x1f380;Rust编程语言入门教程&#xff08;三&#xff09; Hello Cargo&#x1f…

交易所开发:数字市场的核心动力

数字资产交易所作为连接用户与市场的核心枢纽&#xff0c;已成为推动数字经济发展的关键引擎。其开发不仅需要技术创新&#xff0c;还需兼顾用户体验、合规安全与生态构建&#xff0c;以下是交易所开发的核心要素与实践路径分析&#xff1a; 一、交易所的核心定位与技术架构…

Jmeter进阶篇(34)如何解决jmeter.save.saveservice.timestamp_format=ms报错?

问题描述 今天使用Jmeter完成压测执行,然后使用命令将jtl文件转换成html报告时,遇到了报错! 大致就是说jmeter里定义了一个jmeter.save.saveservice.timestamp_format=ms的时间格式,但是jtl文件中的时间格式不是标准的这个ms格式,导致无法正常解析。对于这个问题,有如下…

Navicat17详细安装教程(附最新版本安装包和补丁)2025最详细图文教程安装手册

目录 前言&#xff1a;为什么选择Navicat 17&#xff1f; 一、下载Navicat17安装包 二、安装Navicat 1.运行安装程序 2.启动安装 3.同意“协议” 4.设置安装位置 5.创建桌面图标 6.开始安装 7.安装完成 三、安装补丁 1.解押补丁包 2.在解压后的补丁包目录下找到“w…

一文详解U盘启动Legacy/UEFI方式以及GPT/MBR关系

对于装系统的老手而说一直想研究一下装系统的原理&#xff0c;以及面对一些问题时的解决思路&#xff0c;故对以前的方法进行原理上的解释&#xff0c;主要想理解其底层原理。 引导模式 MBR分区可以同时支持UEFI和Legacy引导&#xff0c;我们可以看一下微pe制作的启动盘&#…