docker-compose.yml 特殊字符转义

MYSQL_ROOT_PASSWORD等键值对,可能会有特殊字符的字符串。使用引号来包围含有特殊字符的字符串。如果含有符号$,使用$$来代表$

You can use a $$ (double-dollar sign) when your configuration needs a literal dollar sign. This also prevents Compose from interpolating a value, so a $$ allows you to refer to environment variables that you don’t want processed by Compose.

Compose file version 3 reference | Docker Documentation

引用:
How to escape # in docker-compose – Stack Overflow
escaping – How can I escape a $ dollar sign in a docker compose file? – Stack Overflow
MYSQL_ROOT_PASSWORD special character missing with docker-compose.yml configuration · Issue #123 · docker-library/mysql · GitHub
yml配置文件中有特殊字符解决方案_iamlzyoco的博客-CSDN博客

MySQL default_character_set_name

SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = "DATABASE_NAME";
ALTER DATABASE DATABASE_NAME CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER DATABASE DATABASE_NAME CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE TABLE_NAME CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE TABLE_NAME CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;

引用:
mysql – How to fix “Incorrect string value” errors? – Stack Overflow
character encoding – How to convert an entire MySQL database characterset and collation to UTF-8? – Stack Overflow

Windows上的MySQL my.cnf my.ini

在Windows上,通常说的/etc/my.cnfmy.ini。如果MySQL已经作为服务启动,那么可以很容易地找到:

Win+R以准备运行,输入services.msc

找到MySQL并查看属性:

“C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe” –defaults-file=”C:\ProgramData\MySQL\MySQL Server 5.7\my.ini” MySQL57

其中defaults-file就是my.ini的路径。

引用:
mysql – I can not find my.cnf on my windows computer – Stack Overflow
mysql – How to change max_allowed_packet size – Stack Overflow
MySQL Bugs: #68516: MySQL workbench installed with MySQL 5.6 links to MySQL55 my.ini

PowerShell Get-FileHash

Get-FileHash
   [-Path] <String[]>
   [[-Algorithm] <String>]
   [<CommonParameters>]
PS D:\Downloads> Get-FileHash .\cn_windows_10_enterprise_ltsc_2019_x64_dvd_9c09ff24.iso -Algorithm SHA1 | Format-List   

Algorithm : SHA1
Hash      : 24B59706D5EDED392423936C82BA5A83596B50CC
Path      : D:\Downloads\cn_windows_10_enterprise_ltsc_2019_x64_dvd_9c09ff24.iso

支持的算法:
SHA1, SHA256, SHA384, SHA512, MD5。

引用:
Get-FileHash

CMake指定源码目录和构建目录

在CMake 3.13或更新的版本中,可以使用:

cmake -S . -B build -G "Unix Makefiles"

来指定当前目录为源码目录,构建二进制文件到build文件夹中。

对于CMake 3.13之前的版本,需要给定没有写在文档中的参数:

cmake -H. -Bbuild -G "Unix Makefiles"

(没有空格)

引用:
configuration – Getting CMake to build out of source without wrapping scripts – Stack Overflow

Node.js http-server

体验应该要好得多。如果你想把它当作一个简单的控制台上的HTTP Server,可以先使用npm安装:

npm install --global http-server

然后就可以使用了:

http-server [path] [options]

使用-p--port来指定端口;使用-a来绑定地址;使用-d来指定目录。更多选项可以看文档。

你也可以直接:

npx http-server [path] [options]

引用:
http-server – npm
http-party/http-server: a simple zero-configuration command-line http server
The npm Blog — Introducing npx: an npm package runner

Python SimpleHTTPServer

这篇并不是在讨论Python HTTP servers的各种用法,而是记录给某些懒人们用的如何启动SimpleHTTPServer。

正如其名,它只是个简单实现,因为安全等因素,你不应该把它用于生产环境。

如果你正在使用Python2,那么你应该:

python -m SimpleHTTPServer 8000

如果你正在使用Python3,那么:

python -m http.server 8000 --bind 127.0.0.1

从3.4开始,引入了参数--bind;从3.6开始,参数--bind支持IPv6。

从3.7开始,可以使用--directory来指定目录。

引用:
SimpleHTTPServer — Simple HTTP request handler
http.server — HTTP servers