TLS/SSL Certificates

使用 OpenSSL 生成自签名证书

当使用不是受信任的第三方 CA 而是自签名的 CA 时,一些浏览器会提示不安全,比如谷歌的 Chrome 浏览器。 ...

February 9, 2021 · 1 min · K8sCat

本地使用 scp 在另外两台服务器之间拷贝文件

scp 可以在两台不同机器之间拷贝文件。 ...

December 30, 2020 · 1 min · K8sCat

记一次 MySQL 启动导致的事故

MySQL 启动存在端口被监听, 但服务没完全启动的情况. ...

December 13, 2020 · 1 min · K8sCat

初识 Makefile 自动化

使用 Makefile 做自动化编译. ...

December 10, 2020 · 1 min · K8sCat

更新已经存在的容器

有一个不知道怎么启动的容器, 由于某些原因会被停掉, 但又不会自动重启, 因为没有设置 restart policy: always. ...

December 10, 2020 · 1 min · K8sCat

Linux 给用户添加 sudo 权限

CentOS7 上新建一个用户(useradd test), 执行命令 sudo yum update, 提示 test 不在 sudoers 文件中。此事将被报告。, 那就添加吧! Q: 什么是 sudo ? 有什么用? A: Sudoers allows particular users to run various commands as the root user, without needing the root password. # 切换到root或者可以执行sudo命令的用户下, 然后编辑 /etc/sudoers sudo vi /etc/sudoers # 添加以下内容(需要使用 :wq! 强制保存) test ALL=(ALL) ALL ...

October 29, 2019 · 1 min · K8sCat

MySQL8 重置密码

MySQL8 忘记密码怎么办? sudo vi /etc/mysql/my.cnf # 添加以下内容 [mysqld] skip-grant-tables # 保存后重启MySQL sudo service mysqld restart # 无密码进入MySQL mysql -uroot -p mysql> alter user 'root'@'%' identified by ''; mysql> flush privileges; mysql> exit # 将配置文件复原 sudo vi /etc/mysql/my.cnf # 注释掉之前添加的内容, 修改为以下内容 [mysqld] # skip-grant-tables # 重启MySQL sudo service mysqld restart # 空密码进入MySQL mysql -uroot -p mysql> alter user 'root'@'%' identified by '123456' mysql> flush privileges; ...

October 29, 2019 · 1 min · K8sCat

CentOS 安装 MySQL

MySQL 被 Oracle 收购后,CentOS 的镜像仓库中提供的默认的数据库也变为了 MariaDB, 那如何在 CentOS 上如何安装 MySQL 呢? 现在一般都是用 Docker, 跑个 MySQL: docker run -d --name mysql8 -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 mysql:8. 本文安装的是 MySQL8 # CentOS7 阿里源 sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo sudo yum update -y # centos7 # 下载mysql的rpm包: https://dev.mysql.com/downloads/repo/yum/ wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm # 安装rpm包 sudo rpm -ivh mysql80-community-release-el7-3.noarch.rpm # 安装MySQL sudo yum install mysql-community-server # 启动MySQL sudo service mysqld start # 查看MySQL状态 # service mysqld status # 获取临时密码 sudo cat /var/log/mysqld.log | grep 'temporary password' > 2019-10-28T04:31:58.792853Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: SAUraYtA3h+s # MySQL 配置文件 # mysql --help Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf # 进入MySQL mysql -uroot -p # 查看当前安全变量值, PS: 这是我修改后的查看的, MySQL8要在修改临时密码后才可以执行下面的命令 # 另外, MySQL57 用的是下划线, 例如: validate_password_policy 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.01 sec) # 设置密码策略, validate_password.policy # 0 or LOW: Length # 1 or MEDIUM: Length; numeric, lowercase/uppercase, and special characters # 2 or STRONG: Length; numeric, lowercase/uppercase, and special characters; dictionary file # global: 全局配置, 但是在MySQL重启后配合 mysql> set global validate_password.policy = 0; # 设置密码至少4位, validate_password.length mysql> set global validate_password.length = 4; # 成功修改密码为 123456 mysql> alter user 'root'@'localhost' identified by '123456' mysql> select user, host, authentication_string from user; +------------------+-----------+ | user | host | +------------------+-----------+ | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | +------------------+-----------+ 4 rows in set (0.00 sec) # 设置所有的IP都可以连接MySQL mysql> update user set host = '%' where user = 'root'; mysql> select user, host, plugin from user; +------------------+-----------+-----------------------+ | user | host | plugin | +------------------+-----------+-----------------------+ | root | % | mysql_native_password | | mysql.infoschema | localhost | caching_sha2_password | | mysql.session | localhost | caching_sha2_password | | mysql.sys | localhost | caching_sha2_password | +------------------+-----------+-----------------------+ 4 rows in set (0.00 sec) # 图形化工具(Navicat)无法连接数据库 # MySQL8 的密码认证插件: caching_sha2_password # MySQL57: mysql_native_password mysql> alter user 'root'@'%' identified with mysql_native_password by '123456'; # 上面的命令会出现问题: ERROR 1524 (HY000): Plugin 'mysql_native_plugin' is not loaded # 通过下面的命令设置认证插件 mysql> update user set plugin='mysql_native_password' where user = 'root'; mysql> alter user 'root'@'%' identified by '123456'; mysql> flush privileges; mysql> exit ...

October 28, 2019 · 3 min · K8sCat