Debian 10 安装 MySQL Server技术
本着一颗折腾的心,折腾快乐。不过这次选择 Debian10,整体还是蛮顺利的,之前在 debian9 上安装 MySQL,默认 MySQL 连密码都没有,总之很难用,安装也不够便捷,Debian10 安装 MySQL8 的安装过程方便多了,mysql_secure_installation 都不需要执行了,安装过程交互界面直接把密码设置好了,由于我使用了更加安全的 caching_sha2_password 导致了数据库在应用程序中无法连接,后面又改成了 mysql native password。
正常安装出现报错:
root@localhost:~# apt install mysql-server Reading package lists... Done Building dependency tree Reading state information... Done Package mysql-server is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'mysql-server' has no installation candidate
安装步骤
apt update apt install gnupg
https://dev.mysql.com/downloads/repo/apt/ 找到最新版本
wget https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb --2020-08-28 09:16:33-- https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11 Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://repo.mysql.com//mysql-apt-config_0.8.15-1_all.deb [following] --2020-08-28 09:16:34-- https://repo.mysql.com//mysql-apt-config_0.8.15-1_all.deb Resolving repo.mysql.com (repo.mysql.com)... 23.45.53.26 Connecting to repo.mysql.com (repo.mysql.com)|23.45.53.26|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 35532 (35K) [application/x-debian-package] Saving to: ‘mysql-apt-config_0.8.15-1_all.deb’ mysql-apt-config_0.8.15-1_all.deb 100%[================================================================================================>] 34.70K --.-KB/s in 0s 2020-08-28 09:16:34 (88.7 MB/s) - ‘mysql-apt-config_0.8.15-1_all.deb’ saved [35532/35532]
dpkg -i mysql-apt-config* ... apt update apt install mysql-server
安装的一些细节
root@localhost:~/bak# dpkg -i mysql-apt-config_0.8.15-1_all.deb (Reading database ... 32090 files and directories currently installed.) Preparing to unpack mysql-apt-config_0.8.15-1_all.deb ... Unpacking mysql-apt-config (0.8.15-1) over (0.8.13-1) ... Setting up mysql-apt-config (0.8.15-1) ... Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package mysql-apt-config) OK root@localhost:~/bak# apt update Hit:1 http://repo.mysql.com/apt/debian buster InRelease Hit:2 http://mirrors.linode.com/debian buster InRelease Hit:3 http://mirrors.linode.com/debian-security buster/updates InRelease Hit:4 http://mirrors.linode.com/debian buster-updates InRelease Get:5 http://repo.mysql.com/apt/debian buster/mysql-8.0 Sources [938 B] Get:6 http://repo.mysql.com/apt/debian buster/mysql-8.0 amd64 Packages [7,172 B] Fetched 8,110 B in 1s (5,865 B/s) Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date. root@localhost:~/bak# apt install mysql-server Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libaio1 libmecab2 libnuma1 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-server mysql-community-server-core The following NEW packages will be installed: libaio1 libmecab2 libnuma1 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-server mysql-community-server-core mysql-server 0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded. Need to get 34.2 MB of archives. After this operation, 313 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://mirrors.linode.com/debian buster/main amd64 libaio1 amd64 0.3.112-3 [11.2 kB] Get:2 http://mirrors.linode.com/debian buster/main amd64 libmecab2 amd64 0.996-6 [258 kB] Get:3 http://repo.mysql.com/apt/debian buster/mysql-8.0 amd64 mysql-common amd64 8.0.21-1debian10 [94.3 kB] Get:4 http://mirrors.linode.com/debian buster/main amd64 libnuma1 amd64 2.0.12-1 [26.2 kB] Get:5 http://mirrors.linode.com/debian buster/main amd64 mecab-utils amd64 0.996-6 [7,700 B] Get:6 http://mirrors.linode.com/debian buster/main amd64 mecab-ipadic all 2.7.0-20070801+main-2.1 [6,714 kB] Get:7 http://repo.mysql.com/apt/debian buster/mysql-8.0 amd64 mysql-community-client-core amd64 8.0.21-1debian10 [1,797 kB] Get:8 http://repo.mysql.com/apt/debian buster/mysql-8.0 amd64 mysql-community-client amd64 8.0.21-1debian10 [2,998 kB] Get:9 http://repo.mysql.com/apt/debian buster/mysql-8.0 amd64 mysql-client amd64 8.0.21-1debian10 [90.8 kB] Get:10 http://repo.mysql.com/apt/debian buster/mysql-8.0 amd64 mysql-community-server-core amd64 8.0.21-1debian10 [22.0 MB] Get:11 http://repo.mysql.com/apt/debian buster/mysql-8.0 amd64 mysql-community-server amd64 8.0.21-1debian10 [101 kB] Get:12 http://repo.mysql.com/apt/debian buster/mysql-8.0 amd64 mysql-server amd64 8.0.21-1debian10 [90.8 kB] Get:13 http://mirrors.linode.com/debian buster/main amd64 mecab-ipadic-utf8 all 2.7.0-20070801+main-2.1 [5,356 B] Fetched 34.2 MB in 2s (13.9 MB/s) Preconfiguring packages ... Selecting previously unselected package mysql-common. (Reading database ... 32090 files and directories currently installed.) Preparing to unpack .../00-mysql-common_8.0.21-1debian10_amd64.deb ... Unpacking mysql-common (8.0.21-1debian10) ... Selecting previously unselected package mysql-community-client-core. Preparing to unpack .../01-mysql-community-client-core_8.0.21-1debian10_amd64.deb ... Unpacking mysql-community-client-core (8.0.21-1debian10) ... Selecting previously unselected package mysql-community-client. Preparing to unpack .../02-mysql-community-client_8.0.21-1debian10_amd64.deb ... Unpacking mysql-community-client (8.0.21-1debian10) ... Selecting previously unselected package mysql-client. Preparing to unpack .../03-mysql-client_8.0.21-1debian10_amd64.deb ... Unpacking mysql-client (8.0.21-1debian10) ... Selecting previously unselected package libaio1:amd64. Preparing to unpack .../04-libaio1_0.3.112-3_amd64.deb ... Unpacking libaio1:amd64 (0.3.112-3) ... Selecting previously unselected package libmecab2:amd64. Preparing to unpack .../05-libmecab2_0.996-6_amd64.deb ... Unpacking libmecab2:amd64 (0.996-6) ... Selecting previously unselected package libnuma1:amd64. Preparing to unpack .../06-libnuma1_2.0.12-1_amd64.deb ... Unpacking libnuma1:amd64 (2.0.12-1) ... Selecting previously unselected package mysql-community-server-core. Preparing to unpack .../07-mysql-community-server-core_8.0.21-1debian10_amd64.deb ... Unpacking mysql-community-server-core (8.0.21-1debian10) ... Selecting previously unselected package mysql-community-server. Preparing to unpack .../08-mysql-community-server_8.0.21-1debian10_amd64.deb ... Unpacking mysql-community-server (8.0.21-1debian10) ... Selecting previously unselected package mecab-utils. Preparing to unpack .../09-mecab-utils_0.996-6_amd64.deb ... Unpacking mecab-utils (0.996-6) ... Selecting previously unselected package mecab-ipadic. Preparing to unpack .../10-mecab-ipadic_2.7.0-20070801+main-2.1_all.deb ... Unpacking mecab-ipadic (2.7.0-20070801+main-2.1) ... Selecting previously unselected package mecab-ipadic-utf8. Preparing to unpack .../11-mecab-ipadic-utf8_2.7.0-20070801+main-2.1_all.deb ... Unpacking mecab-ipadic-utf8 (2.7.0-20070801+main-2.1) ... Selecting previously unselected package mysql-server. Preparing to unpack .../12-mysql-server_8.0.21-1debian10_amd64.deb ... Unpacking mysql-server (8.0.21-1debian10) ... Setting up libmecab2:amd64 (0.996-6) ... Setting up mysql-common (8.0.21-1debian10) ... update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode Setting up mysql-community-client-core (8.0.21-1debian10) ... Setting up mecab-utils (0.996-6) ... Setting up libnuma1:amd64 (2.0.12-1) ... Setting up libaio1:amd64 (0.3.112-3) ... Setting up mysql-community-client (8.0.21-1debian10) ... Setting up mysql-client (8.0.21-1debian10) ... Setting up mecab-ipadic (2.7.0-20070801+main-2.1) ... Compiling IPA dictionary for Mecab. This takes long time... reading /usr/share/mecab/dic/ipadic/unk.def ... 40 emitting double-array: 100% |###########################################| /usr/share/mecab/dic/ipadic/model.def is not found. skipped. reading /usr/share/mecab/dic/ipadic/Noun.org.csv ... 16668 reading /usr/share/mecab/dic/ipadic/Postp.csv ... 146 reading /usr/share/mecab/dic/ipadic/Prefix.csv ... 221 reading /usr/share/mecab/dic/ipadic/Adverb.csv ... 3032 reading /usr/share/mecab/dic/ipadic/Others.csv ... 2 reading /usr/share/mecab/dic/ipadic/Conjunction.csv ... 171 reading /usr/share/mecab/dic/ipadic/Verb.csv ... 130750 reading /usr/share/mecab/dic/ipadic/Noun.verbal.csv ... 12146 reading /usr/share/mecab/dic/ipadic/Symbol.csv ... 208 reading /usr/share/mecab/dic/ipadic/Suffix.csv ... 1393 reading /usr/share/mecab/dic/ipadic/Noun.adjv.csv ... 3328 reading /usr/share/mecab/dic/ipadic/Noun.nai.csv ... 42 reading /usr/share/mecab/dic/ipadic/Auxil.csv ... 199 reading /usr/share/mecab/dic/ipadic/Noun.others.csv ... 151 reading /usr/share/mecab/dic/ipadic/Noun.number.csv ... 42 reading /usr/share/mecab/dic/ipadic/Adnominal.csv ... 135 reading /usr/share/mecab/dic/ipadic/Postp-col.csv ... 91 reading /usr/share/mecab/dic/ipadic/Noun.place.csv ... 72999 reading /usr/share/mecab/dic/ipadic/Filler.csv ... 19 reading /usr/share/mecab/dic/ipadic/Noun.adverbal.csv ... 795 reading /usr/share/mecab/dic/ipadic/Noun.name.csv ... 34202 reading /usr/share/mecab/dic/ipadic/Adj.csv ... 27210 reading /usr/share/mecab/dic/ipadic/Noun.proper.csv ... 27328 reading /usr/share/mecab/dic/ipadic/Noun.csv ... 60477 reading /usr/share/mecab/dic/ipadic/Noun.demonst.csv ... 120 reading /usr/share/mecab/dic/ipadic/Interjection.csv ... 252 emitting double-array: 100% |###########################################| reading /usr/share/mecab/dic/ipadic/matrix.def ... 1316x1316 emitting matrix : 100% |###########################################| done! update-alternatives: using /var/lib/mecab/dic/ipadic to provide /var/lib/mecab/dic/debian (mecab-dictionary) in auto mode Setting up mysql-community-server-core (8.0.21-1debian10) ... Setting up mysql-community-server (8.0.21-1debian10) ... 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. [mysql.conf:23] Line references path below legacy directory /var/run/, updating /var/run/mysqld → /run/mysqld; please update the tmpfiles.d/ drop-in file accordingly. [mysql.conf:23] Line references path below legacy directory /var/run/, updating /var/run/mysqld → /run/mysqld; please update the tmpfiles.d/ drop-in file accordingly. [mysql.conf:23] Line references path below legacy directory /var/run/, updating /var/run/mysqld → /run/mysqld; please update the tmpfiles.d/ drop-in file accordingly. Setting up mecab-ipadic-utf8 (2.7.0-20070801+main-2.1) ... Compiling IPA dictionary for Mecab. This takes long time... reading /usr/share/mecab/dic/ipadic/unk.def ... 40 emitting double-array: 100% |###########################################| /usr/share/mecab/dic/ipadic/model.def is not found. skipped. reading /usr/share/mecab/dic/ipadic/Noun.org.csv ... 16668 reading /usr/share/mecab/dic/ipadic/Postp.csv ... 146 reading /usr/share/mecab/dic/ipadic/Prefix.csv ... 221 reading /usr/share/mecab/dic/ipadic/Adverb.csv ... 3032 reading /usr/share/mecab/dic/ipadic/Others.csv ... 2 reading /usr/share/mecab/dic/ipadic/Conjunction.csv ... 171 reading /usr/share/mecab/dic/ipadic/Verb.csv ... 130750 reading /usr/share/mecab/dic/ipadic/Noun.verbal.csv ... 12146 reading /usr/share/mecab/dic/ipadic/Symbol.csv ... 208 reading /usr/share/mecab/dic/ipadic/Suffix.csv ... 1393 reading /usr/share/mecab/dic/ipadic/Noun.adjv.csv ... 3328 reading /usr/share/mecab/dic/ipadic/Noun.nai.csv ... 42 reading /usr/share/mecab/dic/ipadic/Auxil.csv ... 199 reading /usr/share/mecab/dic/ipadic/Noun.others.csv ... 151 reading /usr/share/mecab/dic/ipadic/Noun.number.csv ... 42 reading /usr/share/mecab/dic/ipadic/Adnominal.csv ... 135 reading /usr/share/mecab/dic/ipadic/Postp-col.csv ... 91 reading /usr/share/mecab/dic/ipadic/Noun.place.csv ... 72999 reading /usr/share/mecab/dic/ipadic/Filler.csv ... 19 reading /usr/share/mecab/dic/ipadic/Noun.adverbal.csv ... 795 reading /usr/share/mecab/dic/ipadic/Noun.name.csv ... 34202 reading /usr/share/mecab/dic/ipadic/Adj.csv ... 27210 reading /usr/share/mecab/dic/ipadic/Noun.proper.csv ... 27328 reading /usr/share/mecab/dic/ipadic/Noun.csv ... 60477 reading /usr/share/mecab/dic/ipadic/Noun.demonst.csv ... 120 reading /usr/share/mecab/dic/ipadic/Interjection.csv ... 252 emitting double-array: 100% |###########################################| reading /usr/share/mecab/dic/ipadic/matrix.def ... 1316x1316 emitting matrix : 100% |###########################################| done! update-alternatives: using /var/lib/mecab/dic/ipadic-utf8 to provide /var/lib/mecab/dic/debian (mecab-dictionary) in auto mode Setting up mysql-server (8.0.21-1debian10) ... Processing triggers for man-db (2.8.5-2) ... Processing triggers for libc-bin (2.28-10) ... root@localhost:~/bak# root@localhost:~/bak# root@localhost:~/bak# netstat -ntl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp6 0 0 :::80 :::* LISTEN tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 :::33060 :::* LISTEN tcp6 0 0 :::3306 :::* LISTEN root@localhost:~/bak# ps aux | grep mysql mysql 14629 1.2 36.0 1273420 364548 ? Ssl 09:20 0:01 /usr/sbin/mysqld root 14854 0.0 0.0 6076 876 pts/0 S+ 09:22 0:00 grep mysql
mysql 的 3306、33060 端口区别
Port 3306 is the default port for the MySQL Protocol, which is used by the mysql client, MySQL Connectors, and utilities such as mysqldump and mysqlpump. Port 33060 is the default port for the MySQL Database Extended Interface (the MySQL X Protocol).
Test
root@localhost:~/bak# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.21 MySQL Community Server - GPL Copyright (c) 2000, 2020, 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> select version(); +-----------+ | version() | +-----------+ | 8.0.21 | +-----------+ 1 row in set (0.00 sec) mysql> mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.05 sec) mysql> select * from mysql.user\G *************************** 1. row *************************** Host: localhost User: mysql.infoschema Select_priv: Y Insert_priv: N Update_priv: N Delete_priv: N Create_priv: N Drop_priv: N Reload_priv: N Shutdown_priv: N Process_priv: N File_priv: N Grant_priv: N References_priv: N Index_priv: N Alter_priv: N Show_db_priv: N Super_priv: N Create_tmp_table_priv: N Lock_tables_priv: N Execute_priv: N Repl_slave_priv: N Repl_client_priv: N Create_view_priv: N Show_view_priv: N Create_routine_priv: N Alter_routine_priv: N Create_user_priv: N Event_priv: N Trigger_priv: N Create_tablespace_priv: N ssl_type: ssl_cipher: 0x x509_issuer: 0x x509_subject: 0x max_questions: 0 max_updates: 0 max_connections: 0 max_user_connections: 0 plugin: caching_sha2_password authentication_string: $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED password_expired: N password_last_changed: 2020-08-28 09:20:11 password_lifetime: NULL account_locked: Y Create_role_priv: N Drop_role_priv: N Password_reuse_history: NULL Password_reuse_time: NULL Password_require_current: NULL User_attributes: NULL *************************** 2. row *************************** Host: localhost User: mysql.session Select_priv: N Insert_priv: N Update_priv: N Delete_priv: N Create_priv: N Drop_priv: N Reload_priv: N Shutdown_priv: Y Process_priv: N File_priv: N Grant_priv: N References_priv: N Index_priv: N Alter_priv: N Show_db_priv: N Super_priv: Y Create_tmp_table_priv: N Lock_tables_priv: N Execute_priv: N Repl_slave_priv: N Repl_client_priv: N Create_view_priv: N Show_view_priv: N Create_routine_priv: N Alter_routine_priv: N Create_user_priv: N Event_priv: N Trigger_priv: N Create_tablespace_priv: N ssl_type: ssl_cipher: 0x x509_issuer: 0x x509_subject: 0x max_questions: 0 max_updates: 0 max_connections: 0 max_user_connections: 0 plugin: caching_sha2_password authentication_string: $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED password_expired: N password_last_changed: 2020-08-28 09:20:11 password_lifetime: NULL account_locked: Y Create_role_priv: N Drop_role_priv: N Password_reuse_history: NULL Password_reuse_time: NULL Password_require_current: NULL User_attributes: NULL *************************** 3. row *************************** Host: localhost User: mysql.sys Select_priv: N Insert_priv: N Update_priv: N Delete_priv: N Create_priv: N Drop_priv: N Reload_priv: N Shutdown_priv: N Process_priv: N File_priv: N Grant_priv: N References_priv: N Index_priv: N Alter_priv: N Show_db_priv: N Super_priv: N Create_tmp_table_priv: N Lock_tables_priv: N Execute_priv: N Repl_slave_priv: N Repl_client_priv: N Create_view_priv: N Show_view_priv: N Create_routine_priv: N Alter_routine_priv: N Create_user_priv: N Event_priv: N Trigger_priv: N Create_tablespace_priv: N ssl_type: ssl_cipher: 0x x509_issuer: 0x x509_subject: 0x max_questions: 0 max_updates: 0 max_connections: 0 max_user_connections: 0 plugin: caching_sha2_password authentication_string: $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED password_expired: N password_last_changed: 2020-08-28 09:20:11 password_lifetime: NULL account_locked: Y Create_role_priv: N Drop_role_priv: N Password_reuse_history: NULL Password_reuse_time: NULL Password_require_current: NULL User_attributes: NULL *************************** 4. row *************************** Host: localhost User: root Select_priv: Y Insert_priv: Y Update_priv: Y Delete_priv: Y Create_priv: Y Drop_priv: Y Reload_priv: Y Shutdown_priv: Y Process_priv: Y File_priv: Y Grant_priv: Y References_priv: Y Index_priv: Y Alter_priv: Y Show_db_priv: Y Super_priv: Y Create_tmp_table_priv: Y Lock_tables_priv: Y Execute_priv: Y Repl_slave_priv: Y Repl_client_priv: Y Create_view_priv: Y Show_view_priv: Y Create_routine_priv: Y Alter_routine_priv: Y Create_user_priv: Y Event_priv: Y Trigger_priv: Y Create_tablespace_priv: Y ssl_type: ssl_cipher: 0x x509_issuer: 0x x509_subject: 0x max_questions: 0 max_updates: 0 max_connections: 0 max_user_connections: 0 plugin: caching_sha2_password M+aJvfJwnGM99L9Q79jp3GEydwzWtBA/EL.Nnfoe23RF/9? password_expired: N password_last_changed: 2020-08-28 09:20:14 password_lifetime: NULL account_locked: N Create_role_priv: Y Drop_role_priv: Y Password_reuse_history: NULL Password_reuse_time: NULL Password_require_current: NULL User_attributes: NULL 4 rows in set (0.00 sec) mysql> exit Bye
PDOException: PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] in Next PDOException: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
还是滚回去比较好,新玩意儿不灵啊,一般 mysql 也都只是支持本地连接,要那么强的验证干嘛呢?好奇心害死猫🐱。
暂无