Debian 11安装mysql 8.0.13
访问页面 https://downloads.mysql.com/archives/community/
Debian 11安装mysql 8.0.13
1、下载mysql安装包
访问官方下载页面下载bundle安装包
https://downloads.mysql.com/archives/community/
下载文件 然后解压
mkdir -p /package/mysql/mysql-server_8.0.13-1debian9_amd64.deb-bundle
tar -xvf /package/mysql/mysql-server_8.0.13-1debian9_amd64.deb-bundle.tar -C /package/mysql/mysql-server_8.0.13-1debian9_amd64.deb-bundle
解压后的文件如图
root@debian:/package/mysql/mysql-server_8.0.13-1debian9_amd64.deb-bundle# ls -lh
total 97M
-rw-r--r-- 1 7155 31415 877K Oct 7 2018 libmysqlclient21_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 1.1M Oct 7 2018 libmysqlclient-dev_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 79K Oct 7 2018 mysql-client_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 83K Oct 7 2018 mysql-common_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 2.2M Oct 7 2018 mysql-community-client_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 1.4M Oct 7 2018 mysql-community-client-core_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 23M Oct 7 2018 mysql-community-server_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 17M Oct 7 2018 mysql-community-server-core_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 52M Oct 7 2018 mysql-community-test_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 79K Oct 7 2018 mysql-server_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 79K Oct 7 2018 mysql-testsuite_8.0.13-1debian9_amd64.deb
root@debian:/Koal/package/mysql/mysql-server_8.0.13-1debian9_amd64.deb-bundle#
2、安装文档
https://dev.mysql.com/doc/mysql-installation-excerpt/8.0/en/linux-installation-debian.html
2.1、安装依赖包
apt-get install libaio1
2.2、安装MySQL包
cd /package/mysql/mysql-server_8.0.13-1debian9_amd64.deb-bundle
dpkg-preconfigure mysql-community-server_*.deb
此步骤会进行设定mysql的root密码
选择mysql加密组件,为了兼容性,可以选择老的加密方式。
包文件如图所示
root@debian:/package/mysql/mysql-server_8.0.13-1debian9_amd64.deb-bundle# ls -lh
total 97M
-rw-r--r-- 1 7155 31415 877K Oct 7 2018 libmysqlclient21_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 1.1M Oct 7 2018 libmysqlclient-dev_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 79K Oct 7 2018 mysql-client_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 83K Oct 7 2018 mysql-common_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 2.2M Oct 7 2018 mysql-community-client_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 1.4M Oct 7 2018 mysql-community-client-core_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 23M Oct 7 2018 mysql-community-server_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 17M Oct 7 2018 mysql-community-server-core_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 52M Oct 7 2018 mysql-community-test_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 79K Oct 7 2018 mysql-server_8.0.13-1debian9_amd64.deb
-rw-r--r-- 1 7155 31415 79K Oct 7 2018 mysql-testsuite_8.0.13-1debian9_amd64.deb
root@debian:/package/mysql/mysql-server_8.0.13-1debian9_amd64.deb-bundle#
安装MySQL包
本次安装失败 是因为依赖关系缺少的依赖包未安装导致导致安装失败
root@debian:package/mysql/mysql-server_8.0.13-1debian9_amd64.deb-bundle# dpkg -i mysql-{common,community-client-core,community-client,client,community-server-core,community-server,server}_*.deb
Selecting previously unselected package mysql-common.
(Reading database ... 136712 files and directories currently installed.)
Preparing to unpack mysql-common_8.0.13-1debian9_amd64.deb ...
Unpacking mysql-common (8.0.13-1debian9) ...
Selecting previously unselected package mysql-community-client-core.
Preparing to unpack mysql-community-client-core_8.0.13-1debian9_amd64.deb ...
Unpacking mysql-community-client-core (8.0.13-1debian9) ...
Selecting previously unselected package mysql-community-client.
Preparing to unpack mysql-community-client_8.0.13-1debian9_amd64.deb ...
Unpacking mysql-community-client (8.0.13-1debian9) ...
Selecting previously unselected package mysql-client.
Preparing to unpack mysql-client_8.0.13-1debian9_amd64.deb ...
Unpacking mysql-client (8.0.13-1debian9) ...
Selecting previously unselected package mysql-community-server-core.
Preparing to unpack mysql-community-server-core_8.0.13-1debian9_amd64.deb ...
Unpacking mysql-community-server-core (8.0.13-1debian9) ...
Selecting previously unselected package mysql-community-server.
Preparing to unpack mysql-community-server_8.0.13-1debian9_amd64.deb ...
Unpacking mysql-community-server (8.0.13-1debian9) ...
Selecting previously unselected package mysql-server.
Preparing to unpack mysql-server_8.0.13-1debian9_amd64.deb ...
Unpacking mysql-server (8.0.13-1debian9) ...
Setting up mysql-common (8.0.13-1debian9) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
dpkg: dependency problems prevent configuration of mysql-community-client-core:
mysql-community-client-core depends on libncurses5 (>= 6); however:
Package libncurses5 is not installed.
mysql-community-client-core depends on libtinfo5 (>= 6); however:
Package libtinfo5 is not installed.
dpkg: error processing package mysql-community-client-core (--install):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mysql-community-client:
mysql-community-client depends on mysql-community-client-core (= 8.0.13-1debian9); however:
Package mysql-community-client-core is not configured yet.
dpkg: error processing package mysql-community-client (--install):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mysql-client:
mysql-client depends on mysql-community-client (= 8.0.13-1debian9); however:
Package mysql-community-client is not configured yet.
dpkg: error processing package mysql-client (--install):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mysql-community-server-core:
mysql-community-server-core depends on libmecab2; however:
Package libmecab2 is not installed.
dpkg: error processing package mysql-community-server-core (--install):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mysql-community-server:
mysql-community-server depends on mysql-client (= 8.0.13-1debian9); however:
Package mysql-client is not configured yet.
mysql-community-server depends on mysql-community-server-core (= 8.0.13-1debian9); however:
Package mysql-community-server-core is not configured yet.
mysql-community-server depends on libmecab2; however:
Package libmecab2 is not installed.
dpkg: error processing package mysql-community-server (--install):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-community-server (= 8.0.13-1debian9); however:
Package mysql-community-server is not configured yet.
dpkg: error processing package mysql-server (--install):
dependency problems - leaving unconfigured
Processing triggers for man-db (2.9.4-2) ...
Errors were encountered while processing:
mysql-community-client-core
mysql-community-client
mysql-client
mysql-community-server-core
mysql-community-server
mysql-server
root@debian:/package/mysql/mysql-server_8.0.13-1debian9_amd64.deb-bundle#
apt-get -f install 修复上述问题
apt-get -f install
安装过程会自动创建MySQL的systemd服务
root@debian:/package/mysql/mysql-server_8.0.13-1debian9_amd64.deb-bundle# apt-get -f install
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
libmecab2 libncurses5 libtinfo5
The following NEW packages will be installed:
libmecab2 libncurses5 libtinfo5
0 upgraded, 3 newly installed, 0 to remove and 210 not upgraded.
6 not fully installed or removed.
Need to get 653 kB of archives.
After this operation, 2,670 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://mirrors.tuna.tsinghua.edu.cn/debian bullseye/main amd64 libmecab2 amd64 0.996-14+b4 [221 kB]
Get:2 https://mirrors.tuna.tsinghua.edu.cn/debian bullseye/main amd64 libtinfo5 amd64 6.2+20201114-2 [336 kB]
Get:3 https://mirrors.tuna.tsinghua.edu.cn/debian bullseye/main amd64 libncurses5 amd64 6.2+20201114-2 [96.8 kB]
Fetched 653 kB in 1s (965 kB/s)
Selecting previously unselected package libmecab2:amd64.
(Reading database ... 136962 files and directories currently installed.)
Preparing to unpack .../libmecab2_0.996-14+b4_amd64.deb ...
Unpacking libmecab2:amd64 (0.996-14+b4) ...
Selecting previously unselected package libtinfo5:amd64.
Preparing to unpack .../libtinfo5_6.2+20201114-2_amd64.deb ...
Unpacking libtinfo5:amd64 (6.2+20201114-2) ...
Selecting previously unselected package libncurses5:amd64.
Preparing to unpack .../libncurses5_6.2+20201114-2_amd64.deb ...
Unpacking libncurses5:amd64 (6.2+20201114-2) ...
Setting up libmecab2:amd64 (0.996-14+b4) ...
Setting up mysql-community-server-core (8.0.13-1debian9) ...
Setting up libtinfo5:amd64 (6.2+20201114-2) ...
Setting up libncurses5:amd64 (6.2+20201114-2) ...
Setting up mysql-community-client-core (8.0.13-1debian9) ...
Setting up mysql-community-client (8.0.13-1debian9) ...
Setting up mysql-client (8.0.13-1debian9) ...
Setting up mysql-community-server (8.0.13-1debian9) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
Setting up mysql-server (8.0.13-1debian9) ...
Processing triggers for libc-bin (2.31-13+deb11u3) ...
root@debian:/package/mysql/mysql-server_8.0.13-1debian9_amd64.deb-bundle#
至此安装MySQL成功,启动MySQL服务
root@debian:/package/mysql# systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-03-31 05:04:56 EDT; 8min ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 3107 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 3142 (mysqld)
Status: "SERVER_OPERATING"
Tasks: 37 (limit: 7035)
Memory: 377.0M
CPU: 3.785s
CGroup: /system.slice/mysql.service
└─3142 /usr/sbin/mysqld
Mar 31 05:04:55 debian systemd[1]: Starting MySQL Community Server...
Mar 31 05:04:56 debian systemd[1]: Started MySQL Community Server.
root@debian:/package/mysql#
root@debian:/package/mysql# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.13 MySQL Community Server - GPL
Copyright (c) 2000, 2018, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql>
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 under /var/lib/mysql
root@debian:~# ls -l /etc/mysql/
total 16
drwxr-xr-x 2 root root 4096 Mar 31 04:56 conf.d
lrwxrwxrwx 1 root root 24 Mar 31 05:04 my.cnf -> /etc/alternatives/my.cnf
-rw-r--r-- 1 root root 1469 Oct 7 2018 my.cnf.fallback
-rw-r--r-- 1 root root 1497 Oct 7 2018 mysql.cnf
drwxr-xr-x 2 root root 4096 Mar 31 05:04 mysql.conf.d
root@debian:~# ls -l /usr/bin/|grep "mysql*"
-rwxr-xr-x 1 root root 5985184 Oct 7 2018 mysql
-rwxr-xr-x 1 root root 5626480 Oct 7 2018 mysqladmin
-rwxr-xr-x 1 root root 6047392 Oct 7 2018 mysqlbinlog
-rwxr-xr-x 1 root root 5639600 Oct 7 2018 mysqlcheck
-rwxr-xr-x 1 root root 5371424 Oct 7 2018 mysql_config_editor
-rwxr-xr-x 1 root root 26716 Oct 7 2018 mysqld_multi
-rwxr-xr-x 1 root root 29769 Oct 7 2018 mysqld_safe
-rwxr-xr-x 1 root root 5697904 Oct 7 2018 mysqldump
-rwxr-xr-x 1 root root 7855 Oct 7 2018 mysqldumpslow
-rwxr-xr-x 1 root root 5622864 Oct 7 2018 mysqlimport
-rwxr-xr-x 1 root root 6310096 Oct 7 2018 mysqlpump
-rwxr-xr-x 1 root root 5611344 Oct 7 2018 mysql_secure_installation
-rwxr-xr-x 1 root root 5617296 Oct 7 2018 mysqlshow
-rwxr-xr-x 1 root root 5640528 Oct 7 2018 mysqlslap
-rwxr-xr-x 1 root root 5393808 Oct 7 2018 mysql_ssl_rsa_setup
-rwxr-xr-x 1 root root 5285152 Oct 7 2018 mysql_tzinfo_to_sql
-rwxr-xr-x 1 root root 11663568 Oct 7 2018 mysql_upgrade
root@debian:~# ls -l /usr/sbin/|grep "mysql*"
-rwxr-xr-x 1 root root 54811120 Oct 7 2018 mysqld
-rwxr-xr-x 1 root root 108243792 Oct 7 2018 mysqld-debug
root@debian:~# ls -l /var/lib/mysql
total 168008
-rw-r----- 1 mysql mysql 56 Mar 31 05:04 auto.cnf
-rw-r----- 1 mysql mysql 471 Mar 31 05:04 binlog.000001
-rw-r----- 1 mysql mysql 155 Mar 31 05:04 binlog.000002
-rw-r----- 1 mysql mysql 32 Mar 31 05:04 binlog.index
-rw------- 1 mysql mysql 1680 Mar 31 05:04 ca-key.pem
-rw-r--r-- 1 mysql mysql 1112 Mar 31 05:04 ca.pem
-rw-r--r-- 1 mysql mysql 1112 Mar 31 05:04 client-cert.pem
-rw------- 1 mysql mysql 1676 Mar 31 05:04 client-key.pem
-rw-r----- 1 mysql mysql 3580 Mar 31 05:04 ib_buffer_pool
-rw-r----- 1 mysql mysql 12582912 Mar 31 05:04 ibdata1
-rw-r----- 1 mysql mysql 50331648 Mar 31 05:04 ib_logfile0
-rw-r----- 1 mysql mysql 50331648 Mar 31 05:04 ib_logfile1
-rw-r----- 1 mysql mysql 12582912 Mar 31 05:04 ibtmp1
drwxr-x--- 2 mysql mysql 4096 Mar 31 05:04 '#innodb_temp'
drwxr-x--- 2 mysql mysql 4096 Mar 31 05:04 mysql
-rw-r----- 1 mysql mysql 25165824 Mar 31 05:04 mysql.ibd
drwxr-x--- 2 mysql mysql 4096 Mar 31 05:04 performance_schema
-rw------- 1 mysql mysql 1680 Mar 31 05:04 private_key.pem
-rw-r--r-- 1 mysql mysql 452 Mar 31 05:04 public_key.pem
-rw-r--r-- 1 mysql mysql 1112 Mar 31 05:04 server-cert.pem
-rw------- 1 mysql mysql 1680 Mar 31 05:04 server-key.pem
drwxr-x--- 2 mysql mysql 4096 Mar 31 05:04 sys
-rw-r----- 1 mysql mysql 10485760 Mar 31 05:04 undo_001
-rw-r----- 1 mysql mysql 10485760 Mar 31 05:04 undo_002
root@debian:~#
3、测试mysql安装
建立数据库
root@debian:~# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.13 MySQL Community Server - GPL
Copyright (c) 2000, 2018, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql> create database test;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql>
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)