我的编程空间,编程开发者的网络收藏夹
学习永远不晚

Debian 11安装mysql 5.7.41

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

Debian 11安装mysql 5.7.41

Debian 11安装mysql 5.7.41

1、下载mysql安装包

访问官方下载页面下载bundle安装包
https://downloads.mysql.com/archives/community/

在这里插入图片描述

下载文件 然后解压

mkdir -p  /root/package/mysql/mysql-server_5.7.41-1debian10_amd64.deb-bundle
cd /root/package/mysql/
tar -xvf mysql-server_5.7.41-1debian10_amd64.deb-bundle.tar -C mysql-server_5.7.41-1debian10_amd64.deb-bundle/

解压后的文件如图

root@debian:~/package/mysql# tar -xvf mysql-server_5.7.41-1debian10_amd64.deb-bundle.tar -C mysql-server_5.7.41-1debian10_amd64.deb-bundle/libmysqlclient20_5.7.41-1debian10_amd64.deblibmysqlclient-dev_5.7.41-1debian10_amd64.deblibmysqld-dev_5.7.41-1debian10_amd64.debmysql-client_5.7.41-1debian10_amd64.debmysql-common_5.7.41-1debian10_amd64.debmysql-community-client_5.7.41-1debian10_amd64.debmysql-community-server_5.7.41-1debian10_amd64.debmysql-community-source_5.7.41-1debian10_amd64.debmysql-community-test_5.7.41-1debian10_amd64.debmysql-server_5.7.41-1debian10_amd64.debmysql-testsuite_5.7.41-1debian10_amd64.debroot@debian:~/package/mysql# 

2、安装文档

https://dev.mysql.com/doc/mysql-installation-excerpt/5.7/en/linux-installation-debian.html

2.1、安装依赖包

apt-get install libaio1

2.2、安装MySQL包

2.2.1、预设置数据库参数

cd /root/package/mysql/mysql-server_5.7.41-1debian10_amd64.deb-bundle/
dpkg-preconfigure mysql-community-server_*.deb

此步骤会进行设定mysql的root账户密码
输入root账户密码

在这里插入图片描述

再次输入密码

在这里插入图片描述

按tab键 选中ok 回车

在这里插入图片描述

包文件如图所示

root@debian:~/package/mysql/mysql-server_5.7.41-1debian10_amd64.deb-bundle# ls -lhtotal 159M-rw-r--r-- 1 7155 31415 1.8M Dec  7 12:50 libmysqlclient20_5.7.41-1debian10_amd64.deb-rw-r--r-- 1 7155 31415 2.3M Dec  7 12:51 libmysqlclient-dev_5.7.41-1debian10_amd64.deb-rw-r--r-- 1 7155 31415  20M Dec  7 12:50 libmysqld-dev_5.7.41-1debian10_amd64.deb-rw-r--r-- 1 7155 31415  69K Dec  7 12:50 mysql-client_5.7.41-1debian10_amd64.deb-rw-r--r-- 1 7155 31415  72K Dec  7 12:50 mysql-common_5.7.41-1debian10_amd64.deb-rw-r--r-- 1 7155 31415  15M Dec  7 12:50 mysql-community-client_5.7.41-1debian10_amd64.deb-rw-r--r-- 1 7155 31415  38M Dec  7 12:50 mysql-community-server_5.7.41-1debian10_amd64.deb-rw-r--r-- 1 7155 31415  52M Dec  7 12:50 mysql-community-source_5.7.41-1debian10_amd64.deb-rw-r--r-- 1 7155 31415  32M Dec  7 12:50 mysql-community-test_5.7.41-1debian10_amd64.deb-rw-r--r-- 1 7155 31415  69K Dec  7 12:51 mysql-server_5.7.41-1debian10_amd64.deb-rw-r--r-- 1 7155 31415  69K Dec  7 12:50 mysql-testsuite_5.7.41-1debian10_amd64.debroot@debian:~/package/mysql/mysql-server_5.7.41-1debian10_amd64.deb-bundle# 

2.2.2、安装MySQL包

安装MySQL包
本次安装失败 是因为依赖关系缺少的依赖包未安装导致导致安装失败

root@debian:~/package/mysql/mysql-server_5.7.41-1debian10_amd64.deb-bundle# dpkg -i mysql-{common,community-client,client,community-server,server}_*.debSelecting previously unselected package mysql-common.(Reading database ... 141511 files and directories currently installed.)Preparing to unpack mysql-common_5.7.41-1debian10_amd64.deb ...Unpacking mysql-common (5.7.41-1debian10) ...Selecting previously unselected package mysql-community-client.Preparing to unpack mysql-community-client_5.7.41-1debian10_amd64.deb ...Unpacking mysql-community-client (5.7.41-1debian10) ...Selecting previously unselected package mysql-client.Preparing to unpack mysql-client_5.7.41-1debian10_amd64.deb ...Unpacking mysql-client (5.7.41-1debian10) ...Selecting previously unselected package mysql-community-server.Preparing to unpack mysql-community-server_5.7.41-1debian10_amd64.deb ...Unpacking mysql-community-server (5.7.41-1debian10) ...Selecting previously unselected package mysql-server.Preparing to unpack mysql-server_5.7.41-1debian10_amd64.deb ...Unpacking mysql-server (5.7.41-1debian10) ...Setting up mysql-common (5.7.41-1debian10) ...update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto modeSetting up mysql-community-client (5.7.41-1debian10) ...Setting up mysql-client (5.7.41-1debian10) ...dpkg: dependency problems prevent configuration of mysql-community-server: mysql-community-server depends on libmecab2; however:  Package libmecab2 is not installed.dpkg: error processing package mysql-community-server (--install): dependency problems - leaving unconfigureddpkg: dependency problems prevent configuration of mysql-server: mysql-server depends on mysql-community-server (= 5.7.41-1debian10); however:  Package mysql-community-server is not configured yet.dpkg: error processing package mysql-server (--install): dependency problems - leaving unconfiguredProcessing triggers for man-db (2.9.4-2) ...Errors were encountered while processing: mysql-community-server mysql-serverroot@debian:~/package/mysql/mysql-server_5.7.41-1debian10_amd64.deb-bundle#

apt-get -f install 修复上述问题

apt-get -f install 

安装过程会自动创建MySQL的systemd服务

root@debian:~/package/mysql/mysql-server_5.7.41-1debian10_amd64.deb-bundle# apt-get -f installReading package lists... DoneBuilding dependency tree... DoneReading state information... DoneCorrecting dependencies... DoneThe following package was automatically installed and is no longer required:  libopengl0Use 'apt autoremove' to remove it.The following additional packages will be installed:  libmecab2The following NEW packages will be installed:  libmecab20 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.2 not fully installed or removed.Need to get 221 kB of archives.After this operation, 1,817 kB of additional disk space will be used.Do you want to continue? [Y/n] yGet:1 https://mirrors.tuna.tsinghua.edu.cn/debian bullseye/main amd64 libmecab2 amd64 0.996-14+b4 [221 kB]Fetched 221 kB in 0s (1,823 kB/s)Selecting previously unselected package libmecab2:amd64.(Reading database ... 141756 files and directories currently installed.)Preparing to unpack .../libmecab2_0.996-14+b4_amd64.deb ...Unpacking libmecab2:amd64 (0.996-14+b4) ...Setting up libmecab2:amd64 (0.996-14+b4) ...Setting up mysql-community-server (5.7.41-1debian10) ...update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto modeCreated symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.Setting up mysql-server (5.7.41-1debian10) ...Processing triggers for libc-bin (2.31-13+deb11u6) ...root@debian:~/package/mysql/mysql-server_5.7.41-1debian10_amd64.deb-bundle#

此次安装是mysql数据库基本安装方式,只安装了这些包。没有安装开发包。

在这里插入图片描述

至此安装MySQL 5.7.41成功,查看MySQL服务状态,在安装时已经设置了开机自启动,不需要可以禁用。

systemctl status mysql.service
root@debian:~/package/mysql# systemctl status mysql.service ● mysql.service - MySQL Community Server     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)     Active: active (running) since Thu 2023-05-11 04:48:39 EDT; 51min ago    Process: 2623 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)    Process: 2679 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)   Main PID: 2685 (mysqld)      Tasks: 27 (limit: 9433)     Memory: 190.5M        CPU: 1.790s     CGroup: /system.slice/mysql.service             └─2685 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pidMay 11 04:48:38 debian systemd[1]: Starting MySQL Community Server...May 11 04:48:39 debian systemd[1]: Started MySQL Community Server.root@debian:~/package/mysql# 

禁用MySQL开机自启动

 systemctl disable mysql.service

2.3、文件安装位置

Here are where the files are installed on the system:

  • All configuration files (like my.cnf) are under /etc/mysql
  • All binaries, libraries, headers, etc., are under /usr/bin and /usr/sbin
  • The data directory is /var/lib/mysql
root@debian:~/package/mysql# ls -lh /etc/mysqltotal 16Kdrwxr-xr-x 2 root root 4.0K May 11 04:47 conf.dlrwxrwxrwx 1 root root   24 May 11 04:48 my.cnf -> /etc/alternatives/my.cnf-rw-r--r-- 1 root root 1.5K Dec  7 13:25 my.cnf.fallback-rw-r--r-- 1 root root 1.2K Dec  7 13:25 mysql.cnfdrwxr-xr-x 2 root root 4.0K May 11 04:48 mysql.conf.droot@debian:~/package/mysql#
root@debian:~/package/mysql# ls -lh /usr/bin/|grep "mysql*"-rwxr-xr-x 1 root root    6.9M Dec  7 13:25 mysql-rwxr-xr-x 1 root root    6.5M Dec  7 13:25 mysqladmin-rwxr-xr-x 1 root root    6.8M Dec  7 13:25 mysqlbinlog-rwxr-xr-x 1 root root    6.5M Dec  7 13:25 mysqlcheck-rwxr-xr-x 1 root root    5.8M Dec  7 13:25 mysql_config_editor-rwxr-xr-x 1 root root     27K Dec  7 13:25 mysqld_multi-rwxr-xr-x 1 root root     28K Dec  7 13:25 mysqld_safe-rwxr-xr-x 1 root root    6.6M Dec  7 13:25 mysqldump-rwxr-xr-x 1 root root    7.7K Dec  7 13:25 mysqldumpslow-rwxr-xr-x 1 root root     27M Dec  7 13:25 mysql_embedded-rwxr-xr-x 1 root root    6.5M Dec  7 13:25 mysqlimport-rwxr-xr-x 1 root root    7.4M Dec  7 13:25 mysql_install_db-rwxr-xr-x 1 root root    5.8M Dec  7 13:25 mysql_plugin-rwxr-xr-x 1 root root    7.2M Dec  7 13:25 mysqlpump-rwxr-xr-x 1 root root    6.5M Dec  7 13:25 mysql_secure_installation-rwxr-xr-x 1 root root    6.5M Dec  7 13:25 mysqlshow-rwxr-xr-x 1 root root    6.5M Dec  7 13:25 mysqlslap-rwxr-xr-x 1 root root    5.8M Dec  7 13:25 mysql_ssl_rsa_setup-rwxr-xr-x 1 root root    3.5M Dec  7 13:25 mysql_tzinfo_to_sql-rwxr-xr-x 1 root root    7.2M Dec  7 13:25 mysql_upgraderoot@debian:~/package/mysql# ls -lh /usr/sbin/|grep "mysql*"-rwxr-xr-x 1 root root    29M Dec  7 13:25 mysqld-rwxr-xr-x 1 root root    46M Dec  7 13:25 mysqld-debugroot@debian:~/package/mysql#
root@debian:~/package/mysql# ls -lh  /var/lib/mysqltotal 121M-rw-r----- 1 mysql mysql   56 May 11 04:48 auto.cnf-rw------- 1 mysql mysql 1.7K May 11 04:48 ca-key.pem-rw-r--r-- 1 mysql mysql 1.1K May 11 04:48 ca.pem-rw-r--r-- 1 mysql mysql 1.1K May 11 04:48 client-cert.pem-rw------- 1 mysql mysql 1.7K May 11 04:48 client-key.pem-rw-r----- 1 mysql mysql  350 May 11 04:48 ib_buffer_pool-rw-r----- 1 mysql mysql  12M May 11 04:48 ibdata1-rw-r----- 1 mysql mysql  48M May 11 04:48 ib_logfile0-rw-r----- 1 mysql mysql  48M May 11 04:48 ib_logfile1-rw-r----- 1 mysql mysql  12M May 11 04:48 ibtmp1drwxr-x--- 2 mysql mysql 4.0K May 11 04:48 mysqldrwxr-x--- 2 mysql mysql 4.0K May 11 04:48 performance_schema-rw------- 1 mysql mysql 1.7K May 11 04:48 private_key.pem-rw-r--r-- 1 mysql mysql  452 May 11 04:48 public_key.pem-rw-r--r-- 1 mysql mysql 1.1K May 11 04:48 server-cert.pem-rw------- 1 mysql mysql 1.7K May 11 04:48 server-key.pemdrwxr-x--- 2 mysql mysql  12K May 11 04:48 sysroot@debian:~/package/mysql#

3、使用mysql 5.7.41 数据库

3.1、命令行登录MySQL 5.7.41 数据库

登录数据库root账户 密码是安装MySQL时设置的root账户密码

mysql -uroot -p
root@debian:~/package/mysql# mysql -uroot -pEnter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.41 MySQL Community Server (GPL)Copyright (c) 2000, 2023, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> 

查看默认所有数据库

show databases;
mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema || sys                |+--------------------+4 rows in set (0.00 sec)mysql> 

创建数据库

create database test;
mysql> create database test;Query OK, 1 row affected (0.00 sec)mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema || sys                || test               |+--------------------+5 rows in set (0.01 sec)mysql> 

3.2、navicat连接mysql 5.7.41 数据库

新建连接 选择mysql

在这里插入图片描述

点击 连接测试

在这里插入图片描述

报错

在这里插入图片描述

需修改以下2点配置解决

3.2.1、修改mysql配置文件允许监听所有网卡地址

原因是默认安装完mysql后 只允许在mysql服务器本机发起数据库连接

 ss -anlp|grep 3306

在这里插入图片描述

本机可以通3306

在这里插入图片描述

外部机器不可以通3306

在这里插入图片描述

修改MySQL配置文件 使得MySQL监听在所有网卡上,也就是允许所有IP地址发起数据库连接

cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf.bak
/etc/mysql/mysql.conf.d/mysqld.cnf

编辑MySQL配置文件

vi /etc/mysql/mysql.conf.d/mysqld.cnf

修改bind-address = 127.0.0.1

在这里插入图片描述

修改为:bind-address = 0.0.0.0

在这里插入图片描述

重启MySQL服务

systemctl restart mysql.service

再次查看监听配置

ss -anlp|grep 3306

在这里插入图片描述

navicat测试连接数据库 仍然报错
在这里插入图片描述

Windows机器telnet 数据库IP 3306 测试

在这里插入图片描述

3.2.2、修改配置允许使用mysql root用户连接数据库

修改配置允许使用mysql root用户连接数据库
登录MySQL数据库

mysql -uroot -p

修改修改配置使得可以允许外部所有IP地址发起数据库连接,用户是root 密码是password(安装时设置的MySQL的root账户密码) ,拥有所有库和表的访问权限。

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> commit;Query OK, 0 rows affected (0.00 sec)mysql> 

navicat再次测试连接 连接成功
在这里插入图片描述

在这里插入图片描述

新建查询

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

3.3、mysql数据库常用命令<5.7.41版本>

3.3.1、初始化默认数据库

初始化默认数据库

mysqld --initialize --console

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

mysqld命令帮助查看:

mysqld --verbose --help|less

在这里插入图片描述

来源地址:https://blog.csdn.net/OceanWaves1993/article/details/130622988

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

Debian 11安装mysql 5.7.41

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

Debian 10安装 MySQL8

登录mysql官网: https://dev.mysql.com/downloads/   选择: https://dev.mysql.com/downloads/repo/apt/   wget 下载: wget https://dev.mysql.com/
Debian 10安装 MySQL8
2021-10-18

Debian 9安装 Python3.7

问题一zipimport.ZipImportError: can't decompress data; zlib not availableMakefile:1130: recipe for target 'install' failedm
2023-01-31

nodejs安装npm debian 9

Node.js是一种快速的开源JavaScript运行环境,能够在服务器端执行JavaScript代码。NPM是Node.js的官方包管理器,它能够帮助您在Node.js环境中安装和管理各种模块(或包)。在本文中,我们将学习如何在Debian 9中安装Node.js并使其自带的包管理器NPM可用。步骤1 - 安装Node.js首先,我们需要在Debian 9上安装Node.js
2023-05-14

Debian下如何安装Myeclipse

这篇文章主要讲解了“Debian下如何安装Myeclipse”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Debian下如何安装Myeclipse”吧!eclipse-SDK-3.2-lin
2023-06-03

Debian下如何安装Eclipse

本篇内容主要讲解“Debian下如何安装Eclipse”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Debian下如何安装Eclipse”吧!在www.eclipse.org下载eclipse-
2023-06-03

如何安装Debian/Ubuntu Git

小编给大家分享一下如何安装Debian/Ubuntu Git,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!Git 是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。Git 是 Linus Torvald
2023-06-27

Debian下如何安装pureftpd

这篇文章主要介绍了Debian下如何安装pureftpd,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。1. 安装(我用的是unstable)apt-get install p
2023-06-16

在Debian中如何安装PHP、MySQL和Apache组件

在Debian中轻松安装PHP、MySQL和Apache,只需按照本文中分步指南即可。文章涵盖了从安装各个组件到配置Apache虚拟主机的详细步骤,并提供了测试安装和其他有用提示。
在Debian中如何安装PHP、MySQL和Apache组件
2024-04-12

在Debian中如何安装PHP、MySQL和Apache组件

要在Debian中安装PHP、MySQL和Apache组件,可以按照以下步骤操作:安装Apache服务器:sudo apt updatesudo apt install apache2安装MySQL数据库服务器:sudo apt inst
在Debian中如何安装PHP、MySQL和Apache组件
2024-04-09

Debian服务器之安装Python3.

1、系统环境介绍    1.1 系统版本        debian-9.6.0-amd64-netinst    1.2 系统内核        Linux lnnkee 4.9.0-8-amd64 #1 SMP Debian 4.9.1
2023-01-31

Debian下安装Java的步骤

这篇文章主要介绍“Debian下安装Java的步骤”,在日常操作中,相信很多人在Debian下安装Java的步骤问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Debian下安装Java的步骤”的疑惑有所帮助!
2023-06-03

debian安装软件包的方式

本篇内容介绍了“debian安装软件包的方式”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!先介绍一下环境:虚拟机:debian7.2.0主机
2023-06-13

debian安装firewalld错误怎么办

这篇文章主要介绍了debian安装firewalld错误怎么办的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇debian安装firewalld错误怎么办文章都会有所收获,下面我们一起来看看吧。debian或ub
2023-07-04

编程热搜

目录