apt-get 安装 mysql
root@node140:~# apt-get install mysql-server
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
下列软件包是自动安装的并且现在不需要了:
fbterm imageworsener libc-ares2 libde265-0 libheif1 liblqr-1-0 libmaxminddb0 libqtermwidget5-0 libsbc1 libsmi2ldbl libspandsp2 libutf8proc2 libwireshark-data
libwireshark11 libwiretap8 libwscodecs2 libwsutil9 qtermwidget5-data squashfs-tools
使用'apt autoremove'来卸载它(它们)。
将会同时安装下列软件:
libcgi-fast-perl libcgi-pm-perl libevent-core-2.1-6 libevent-extra-2.1-6 libfcgi-perl libhtml-template-perl libmecab2 mysql-client-5.7 mysql-client-core-5.7
mysql-server-5.7 mysql-server-core-5.7
建议安装:
libipc-sharedcache-perl mailx tinyca
下列【新】软件包将被安装:
libcgi-fast-perl libcgi-pm-perl libevent-core-2.1-6 libevent-extra-2.1-6 libfcgi-perl libhtml-template-perl libmecab2 mysql-client-5.7 mysql-client-core-5.7
mysql-server mysql-server-5.7 mysql-server-core-5.7
升级了 0 个软件包,新安装了 12 个软件包,要卸载 0 个软件包,有 232 个软件包未被升级。
需要下载 20.6 MB 的归档。
解压缩后会消耗 178 MB 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 https://enterprise-packages.chinauos.com/server-enterprise fou/sp3/main mips64el mysql-client-core-5.7 mips64el 5.7.26-1 [6,777 kB]
获取:2 https://enterprise-packages.chinauos.com/server-enterprise fou/sp3/main mips64el mysql-client-5.7 mips64el 5.7.26-1 [2,430 kB]
获取:3 https://enterprise-packages.chinauos.com/server-enterprise fou/sp3/main mips64el mysql-server-core-5.7 mips64el 5.7.26-1 [7,370 kB]
获取:4 https://enterprise-packages.chinauos.com/server-enterprise fou/sp3/main mips64el libevent-core-2.1-6 mips64el 2.1.8-stable-4 [116 kB]
获取:5 https://enterprise-packages.chinauos.com/server-enterprise fou/sp3/main mips64el libevent-extra-2.1-6 mips64el 2.1.8-stable-4 [93.0 kB]
获取:6 https://enterprise-packages.chinauos.com/server-enterprise fou/sp3/main mips64el libmecab2 mips64el 0.996-6 [212 kB]
获取:7 https://enterprise-packages.chinauos.com/server-enterprise fou/sp3/main mips64el mysql-server-5.7 mips64el 5.7.26-1 [3,239 kB]
获取:8 https://enterprise-packages.chinauos.com/server-enterprise fou/sp3/main mips64el libcgi-pm-perl all 4.40-1 [223 kB]
获取:9 https://enterprise-packages.chinauos.com/server-enterprise fou/sp3/main mips64el libfcgi-perl mips64el 0.78-2+b3 [36.7 kB]
获取:10 https://enterprise-packages.chinauos.com/server-enterprise fou/sp3/main mips64el libcgi-fast-perl all 1:2.13-1 [11.5 kB]
获取:11 https://enterprise-packages.chinauos.com/server-enterprise fou/sp3/main mips64el libhtml-template-perl all 2.97-1 [66.1 kB]
获取:12 https://enterprise-packages.chinauos.com/server-enterprise fou/sp3/main mips64el mysql-server all 5.7.26-1 [11.2 kB]
已下载 20.6 MB,耗时 5秒 (4,327 kB/s)
正在预设定软件包 ...
正在选中未选择的软件包 mysql-client-core-5.7。
(正在读取数据库 ... 系统当前共安装有 180370 个文件和目录。)
准备解压 .../00-mysql-client-core-5.7_5.7.26-1_mips64el.deb ...
正在解压 mysql-client-core-5.7 (5.7.26-1) ...
正在选中未选择的软件包 mysql-client-5.7。
准备解压 .../01-mysql-client-5.7_5.7.26-1_mips64el.deb ...
正在解压 mysql-client-5.7 (5.7.26-1) ...
正在选中未选择的软件包 mysql-server-core-5.7。
准备解压 .../02-mysql-server-core-5.7_5.7.26-1_mips64el.deb ...
正在解压 mysql-server-core-5.7 (5.7.26-1) ...
正在选中未选择的软件包 libevent-core-2.1-6:mips64el。
准备解压 .../03-libevent-core-2.1-6_2.1.8-stable-4_mips64el.deb ...
正在解压 libevent-core-2.1-6:mips64el (2.1.8-stable-4) ...
正在选中未选择的软件包 libevent-extra-2.1-6:mips64el。
准备解压 .../04-libevent-extra-2.1-6_2.1.8-stable-4_mips64el.deb ...
正在解压 libevent-extra-2.1-6:mips64el (2.1.8-stable-4) ...
正在选中未选择的软件包 libmecab2:mips64el。
准备解压 .../05-libmecab2_0.996-6_mips64el.deb ...
正在解压 libmecab2:mips64el (0.996-6) ...
正在选中未选择的软件包 mysql-server-5.7。
准备解压 .../06-mysql-server-5.7_5.7.26-1_mips64el.deb ...
正在解压 mysql-server-5.7 (5.7.26-1) ...
正在选中未选择的软件包 libcgi-pm-perl。
准备解压 .../07-libcgi-pm-perl_4.40-1_all.deb ...
正在解压 libcgi-pm-perl (4.40-1) ...
正在选中未选择的软件包 libfcgi-perl。
准备解压 .../08-libfcgi-perl_0.78-2+b3_mips64el.deb ...
正在解压 libfcgi-perl (0.78-2+b3) ...
正在选中未选择的软件包 libcgi-fast-perl。
准备解压 .../09-libcgi-fast-perl_1%3a2.13-1_all.deb ...
正在解压 libcgi-fast-perl (1:2.13-1) ...
正在选中未选择的软件包 libhtml-template-perl。
准备解压 .../10-libhtml-template-perl_2.97-1_all.deb ...
正在解压 libhtml-template-perl (2.97-1) ...
正在选中未选择的软件包 mysql-server。
准备解压 .../11-mysql-server_5.7.26-1_all.deb ...
正在解压 mysql-server (5.7.26-1) ...
正在设置 libmecab2:mips64el (0.996-6) ...
正在设置 libcgi-pm-perl (4.40-1) ...
正在设置 mysql-server-core-5.7 (5.7.26-1) ...
正在设置 libhtml-template-perl (2.97-1) ...
正在设置 mysql-client-core-5.7 (5.7.26-1) ...
正在设置 libevent-core-2.1-6:mips64el (2.1.8-stable-4) ...
正在设置 libfcgi-perl (0.78-2+b3) ...
正在设置 libevent-extra-2.1-6:mips64el (2.1.8-stable-4) ...
正在设置 libcgi-fast-perl (1:2.13-1) ...
正在设置 mysql-client-5.7 (5.7.26-1) ...
正在设置 mysql-server-5.7 (5.7.26-1) ...
Renaming removed key_buffer and myisam-recover options (if present)
Please enable --log-error option or set appropriate redirections for standard output and/or standard error in daemon mode.
Warning: Unable to start the server.
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
正在设置 mysql-server (5.7.26-1) ...
正在处理用于 systemd (241.8-1+dde) 的触发器 ...
正在处理用于 man-db (2.8.5-2) 的触发器 ...
正在处理用于 libc-bin (2.28.10-1+dde) 的触发器 ...
## 安装过程中并没有提示root的密码,需要在该路径下查看root密码
root@node140:~# vim /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = Io7koNRVbKSFpLLK
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = Io7koNRVbKSFpLLK
socket = /var/run/mysqld/mysqld.sock
root@node140:~# sz /etc/mysql/debian.cnf
# 用上边的用户密码链接mysql
root@node140:~# mysql -u debian-sys-maint -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.26-1 (Uos)
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> update mysql.user set authentication_string=PASSWORD('root') ,plugin='mysql_native_password' where user='root';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
### 上边报错的意思是: 你的密码不符合策略要求
### 那就查看当前的策略呗
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+--------------------------------------+--------+
7 rows in set (0.01 sec)
### 那就修改密码的验证强度等级为LOW
mysql> set global validate_password_policy=LOW;
Query OK, 0 rows affected (0.00 sec)
### 设置全局密码参数长度为4
mysql> set global validate_password_length=4;
Query OK, 0 rows affected (0.01 sec)
### 修改 mysql 密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.00 sec)
mysql>
## 解决 1130 - Host '10.17.13.200' is not allowed to connect to this MySQL server 错误
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select host from user where user='root';
+-----------+
| host |
+-----------+
| localhost |
+-----------+
1 row in set (0.00 sec)
## host= localhost 表示只能通过本机客户端去访问。
## 而设置host=%(是个通配符) 表示所有IP都有连接权限。
mysql> update user set host = '%' where user ='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
## 刷新配置,使配置立即生效
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql 密码强度
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: root