首页 > 数据库 >安装MySQL8.0.x并修改密码

安装MySQL8.0.x并修改密码

时间:2024-03-28 23:12:32浏览次数:15  
标签:NO enum 修改 密码 MySQL8.0 mysql MySQL password priv

安装MySQL8.0.x并修改密码

https://mysql.net.cn/doc/refman/8.0/en/docker-mysql-getting-started.html

拉取镜像

debian@debian:~$ sudo docker pull mysql:8.0.25
[sudo] password for debian:
8.0.25: Pulling from library/mysql
b4d181a07f80: Pull complete
a462b60610f5: Pull complete
578fafb77ab8: Pull complete
524046006037: Pull complete
d0cbe54c8855: Pull complete
aa18e05cc46d: Pull complete
32ca814c833f: Pull complete
9ecc8abdb7f5: Pull complete
ad042b682e0f: Pull complete
71d327c6bb78: Pull complete
165d1d10a3fa: Pull complete
2f40c47d0626: Pull complete
Digest: sha256:52b8406e4c32b8cf0557f1b74517e14c5393aff5cf0384eff62d9e81f4985d4b
Status: Downloaded newer image for mysql:8.0.25
docker.io/library/mysql:8.0.25

运行

debian@debian:~$ sudo mkdir -p /opt/docker_v/mysql/conf
debian@debian:~$ sudo docker run --name mysql \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=123456 \
-v /opt/docker_v/mysql/conf:/etc/mysql/conf.d \
-d mysql:8.0.25
0cbb869d76c23c839ac3e47206c7191e468eeddbefa2e540456c6c4b193b9af2
debian@debian:~$ sudo docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS                                                  NAMES
0cbb869d76c2   mysql:8.0.25   "docker-entrypoint.s…"   34 seconds ago   Up 33 seconds   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   mysql
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.25 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.007 sec)

MySQL [(none)]> 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 [mysql]> show tables;
+------------------------------------------------------+
| Tables_in_mysql                                      |
+------------------------------------------------------+
| columns_priv                                         |
| component                                            |
| db                                                   |
| default_roles                                        |
| engine_cost                                          |
| func                                                 |
| general_log                                          |
| global_grants                                        |
| gtid_executed                                        |
| help_category                                        |
| help_keyword                                         |
| help_relation                                        |
| help_topic                                           |
| innodb_index_stats                                   |
| innodb_table_stats                                   |
| password_history                                     |
| plugin                                               |
| procs_priv                                           |
| proxies_priv                                         |
| replication_asynchronous_connection_failover         |
| replication_asynchronous_connection_failover_managed |
| role_edges                                           |
| server_cost                                          |
| servers                                              |
| slave_master_info                                    |
| slave_relay_log_info                                 |
| slave_worker_info                                    |
| slow_log                                             |
| tables_priv                                          |
| time_zone                                            |
| time_zone_leap_second                                |
| time_zone_name                                       |
| time_zone_transition                                 |
| time_zone_transition_type                            |
| user                                                 |
+------------------------------------------------------+
35 rows in set (0.007 sec)

MySQL [mysql]>
MySQL [mysql]> desc user;
+--------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Field                    | Type                              | Null | Key | Default               | Extra |
+--------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Host                     | char(255)                         | NO   | PRI |                       |       |
| User                     | char(32)                          | NO   | PRI |                       |       |
| Select_priv              | enum('N','Y')                     | NO   |     | N                     |       |
| Insert_priv              | enum('N','Y')                     | NO   |     | N                     |       |
| Update_priv              | enum('N','Y')                     | NO   |     | N                     |       |
| Delete_priv              | enum('N','Y')                     | NO   |     | N                     |       |
| Create_priv              | enum('N','Y')                     | NO   |     | N                     |       |
| Drop_priv                | enum('N','Y')                     | NO   |     | N                     |       |
| Reload_priv              | enum('N','Y')                     | NO   |     | N                     |       |
| Shutdown_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Process_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| File_priv                | enum('N','Y')                     | NO   |     | N                     |       |
| Grant_priv               | enum('N','Y')                     | NO   |     | N                     |       |
| References_priv          | enum('N','Y')                     | NO   |     | N                     |       |
| Index_priv               | enum('N','Y')                     | NO   |     | N                     |       |
| Alter_priv               | enum('N','Y')                     | NO   |     | N                     |       |
| Show_db_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| Super_priv               | enum('N','Y')                     | NO   |     | N                     |       |
| Create_tmp_table_priv    | enum('N','Y')                     | NO   |     | N                     |       |
| Lock_tables_priv         | enum('N','Y')                     | NO   |     | N                     |       |
| Execute_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| Repl_slave_priv          | enum('N','Y')                     | NO   |     | N                     |       |
| Repl_client_priv         | enum('N','Y')                     | NO   |     | N                     |       |
| Create_view_priv         | enum('N','Y')                     | NO   |     | N                     |       |
| Show_view_priv           | enum('N','Y')                     | NO   |     | N                     |       |
| Create_routine_priv      | enum('N','Y')                     | NO   |     | N                     |       |
| Alter_routine_priv       | enum('N','Y')                     | NO   |     | N                     |       |
| Create_user_priv         | enum('N','Y')                     | NO   |     | N                     |       |
| Event_priv               | enum('N','Y')                     | NO   |     | N                     |       |
| Trigger_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| Create_tablespace_priv   | enum('N','Y')                     | NO   |     | N                     |       |
| ssl_type                 | enum('','ANY','X509','SPECIFIED') | NO   |     |                       |       |
| ssl_cipher               | blob                              | NO   |     | NULL                  |       |
| x509_issuer              | blob                              | NO   |     | NULL                  |       |
| x509_subject             | blob                              | NO   |     | NULL                  |       |
| max_questions            | int unsigned                      | NO   |     | 0                     |       |
| max_updates              | int unsigned                      | NO   |     | 0                     |       |
| max_connections          | int unsigned                      | NO   |     | 0                     |       |
| max_user_connections     | int unsigned                      | NO   |     | 0                     |       |
| plugin                   | char(64)                          | NO   |     | caching_sha2_password |       |
| authentication_string    | text                              | YES  |     | NULL                  |       |
| password_expired         | enum('N','Y')                     | NO   |     | N                     |       |
| password_last_changed    | timestamp                         | YES  |     | NULL                  |       |
| password_lifetime        | smallint unsigned                 | YES  |     | NULL                  |       |
| account_locked           | enum('N','Y')                     | NO   |     | N                     |       |
| Create_role_priv         | enum('N','Y')                     | NO   |     | N                     |       |
| Drop_role_priv           | enum('N','Y')                     | NO   |     | N                     |       |
| Password_reuse_history   | smallint unsigned                 | YES  |     | NULL                  |       |
| Password_reuse_time      | smallint unsigned                 | YES  |     | NULL                  |       |
| Password_require_current | enum('N','Y')                     | YES  |     | NULL                  |       |
| User_attributes          | json                              | YES  |     | NULL                  |       |
+--------------------------+-----------------------------------+------+-----+-----------------------+-------+
51 rows in set (0.007 sec)
MySQL [mysql]> select Host, User, Select_priv, authentication_string, plugin from user;
+-----------+------------------+-------------+------------------------------------------------------------------------+-----------------------+
| Host      | User             | Select_priv | authentication_string                                                  | plugin                |
+-----------+------------------+-------------+------------------------------------------------------------------------+-----------------------+
| %         | root             | Y           | $A$005$6{YD~&i`}+)*`hP61P/bDOzJm3FN9GmsvaJE86cs95yPKSMTVcavJLu7        | caching_sha2_password |
| localhost | mysql.infoschema | Y           | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.session    | N           | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.sys        | N           | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | root             | Y           | $A$005$7,7Y]bq:CP.~,_Cb.qi5ELWXFfE2Hvcg2dLaCZCpe0/EbQzcQsPgUo8NX9      | caching_sha2_password |
+-----------+------------------+-------------+------------------------------------------------------------------------+-----------------------+
5 rows in set (0.003 sec)

MySQL [mysql]> SHOW VARIABLES LIKE 'validate_password%';
Empty set (0.004 sec)

MySQL [mysql]> INSTALL COMPONENT 'file://component_validate_password';
Query OK, 0 rows affected (0.011 sec)

# mysql默认密码安全策略
MySQL [mysql]> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password.check_user_name    | ON     |
| 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.004 sec)

MySQL [mysql]> ALTER USER root@localhost IDENTIFIED BY '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

┌──(kali㉿kali)-[~]
└─$ mysql -u root -h 192.168.108.106 -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.25 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> ALTER USER 'root'@'%' IDENTIFIED BY 'jK123456.';
Query OK, 0 rows affected (0.018 sec)

MySQL [(none)]> exit;
Bye

┌──(kali㉿kali)-[~]
└─$ mysql -u root -h 192.168.108.106 -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 8.0.25 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> quit;
Bye

Password Validation Options and Variables:https://dev.mysql.com/doc/refman/8.0/en/validate-password-options-variables.html

总结

- 安装validate_password组件:INSTALL COMPONENT 'file://component_validate_password';
- 查看默认密码安全策略:SHOW VARIABLES LIKE 'validate_password%';
- 修改远程登录密码:ALTER USER 'root'@'%' IDENTIFIED BY 'jK123456.';
- 修改本地登录密码:ALTER USER 'root'@'localhost' IDENTIFIED BY 'asD123456.jk';

标签:NO,enum,修改,密码,MySQL8.0,mysql,MySQL,password,priv
From: https://www.cnblogs.com/swallow010/p/18102845

相关文章

  • 在C语言中,可以通过指针来修改它所指向的内存位置的内容
    在C语言中,可以通过指针来修改它所指向的内存位置的内容。下面是一个例子:#include<stdio.h>intmain(){inta=10;//定义一个变量a,并初始化为10int*p=&a;//定义一个指针p,让它指向a的地址*p=20;//通过指针p修改它所指向的内存位置(即变量......
  • vue extends继承后修改template的解决方案
    vueextends继承后怎么注入虚拟DOM节点1.需求使用extends继承一个组件并在上面做功能的修改和扩展,同时需要小小修改一部分的template。2.extend原理使用extends时,你实际上是创建了一个新组件,它包含了父组件的所有选项和数据,但是你可以覆盖或添加新的选项。3.问题修改通过ext......
  • Linux修改时间
    服务器时间与网络时间不符:一、手动修改date命令:查看当前时间date-s时分秒:修改时间还需要把日期改过来3.date-s完整日期时间(YYYY-MM-DDhh:mm[:ss]):修改日期、时间时间要用双引号括起来,否则报错手动修改会存在一定的时间误差4.hwclock-w将时间写入bio......
  • dubhe2024 BuggyAllocator:通过修改_IO_2_1_stdout_的内容进行任意读
    在堆题中遇到没有show()函数的情况,导致无法泄露地址。这时可以通过修改_IO_2_1_stdout_来强制程序输出一段内存,从而泄露需要的地址。例题:dubhe2024BuggyAllocatordubhe2024,xctf分站赛最后一场凄惨爆零,主看了这道题一整天,逆清楚了但找不到漏洞。事后来看当时就算找到洞了也不会......
  • Excel生成随机密码
    针对生成一个8到12位包含大小写字母、数字、以及特殊字符的随机密码的需求,我们可以采用VBA来实现,以确保每种字符至少包含一次,同时随机生成密码长度。下面是一个更贴近需求的VBA函数示例:FunctionGenerateComplexPassword()AsStringDimpasswordLengthAsIntegerDim......
  • 基于 MCSDK5.4.8 电机库修改两电阻采样方法
    1.前言在当前使用的电机电阻采样方式中分为单电阻,双电阻,三电阻三种方式,其中在STMCSDK5.4库中支持了两种采样方式,单电阻和三电阻,在市面还存在另外一种采样方式,即双电阻采样,本文讨论的是如何修改现有驱动库支持该种采样方式。2.电流双电阻采样机理图1.双电阻采样结......
  • 【Web】随便聊聊应用ASM CoreAPI修改字节码那些事
    目录前言ASM概念Java字节码&ClassFile核心理念:拆分修改重组修改字节码最简化模型代码示例ASM修改类的基本信息ASM修改类的字段ASM修改类的方法常规实现AdviceAdapter实现前言本文速通下ASM最最萌新直观的部分,理解浅薄,纯小白文pom依赖<dependencies><depe......
  • Centos7修改默认网卡名(改为eth0)以及网卡启动报错RTNETLINK answers File exists处理
    Centos7修改默认网卡名(改为eth0)以及网卡启动报错RTNETLINKanswers:Fileexists处理安装好centos7版本的系统后,发现默认的网卡名字有点怪,为了便于管理,可以手动修改。下面对centos7版本下网卡重命名操作做一记录:1.编辑网卡信息[root@web~]#cd/etc/sysconfig/network-scripts/......
  • Linux系统误修改/etc/fstab后无法重启电脑的解决方法(已解决)
     文章目录一、问题:Linux/UOS系统修改fstab文件后导致无法重启机器二、解决方法 一、问题:Linux/UOS系统修改fstab文件后导致无法重启机器本来是想开机自动挂载新装的硬盘,没看清改了系统盘的挂载点,于是重启后无法开机,报了一堆Fail错误,也没办法进入Recovery模式,于是尝试......
  • 使用宝塔面板自建bitwarden(vaultwarden)密码管理器服务器
    参考:bitwarden(vaultwarden)密码管理器自建服务器-腾讯云开发者社区-腾讯云Docker部署Vaultwarden,并使用Nginx反向代理实现Https-Alain'sBlogInstallandSyncAllofYourDevices|Bitwarden 一、准备:域名+ssl+服务器二、步骤1、打开宝塔面板docker管理工具,在应用......