---------------------------------------- cheat sheet ---------------------------------------- https://spacetrack.github.io/cheat-sheet.txt ---------------------------------------- 2020-06-03, 19:15 ---------------------------------------- go_000_0000 table of contents go_100_0000 ... go_200_0000 ... go_300_0000 ... go_400_0000 ... go_401_0050 Random go_401_0060 curl examples go_402_0000 crypto go_402_0100 openssl go_402_0110 encryption with openssl go_402_0120 run a web-server with openssl go_402_0200 hashing go_402_0210 proof to be first author go_403_0000 bash go_403_0010 bash: redirect stdin stdout stderr go_403_0020 bash: for loops go_403_0030 bash: multidimensional arrays go_404_0000 windows powershell go_404_0001 windows powershell: get version go_404_0002 windows powershell: force to use UTF-8, ascii, ... go_404_0010 windows powershell: run command elevated go_404_0020 windows powershell: send e-mail go_404_0030 windows powershell: taskschd windows cron go_404_0035 windows powershell: find file go_404_0040 windows powershell: find string in files (grep -r) go_404_0041 windows powershell: get number of lines (wc -l) go_404_0045 windows powershell: URL encode / decode go_404_0046 windows powershell: BASE64 encode / decode go_404_0050 windows powershell: GUID go_410_0000 linux admin go_410_0010 linux version go_410_0015 linux reboot needed go_410_0100 linux ubuntu resize partition go_411_0000 windows admin go_411_0100 windows admin: listening to port go_420_0001 tmux go_421_0000 ssh go_421_0001 ssh: run an HTTP server on remote node and browse through local web go_500_0000 ... go_501_0010 FFMPEG go_501_0020 mstsc go_502_0000 haproxy go_502_0010 haproxy: validate config go_503_0000 what is my ip address go_503_0020 what is my ip address: get external ip address go_590_0000 Azure go_590_0001 download attachments of Azure DevOps work item go_600_0000 development go_601_0000 git go_601_0010 git log: simple and well formatted go_601_0015 git tag: list tags in MAJOR-MINOR-PATCH-order go_601_0020 git merge: dry run go_602_0000 go(lang) go_602_0010 go(lang) in docker go_602_1000 go(lang) programming go_603_0000 c# go_603_0100 c# dotnet commands go_603_1000 c# dotnet programming go_603_1010 c# dotnet programming: Refresh ASP.NET Core MVC view without reloading the application go_604_0000 java go_604_0100 java commmands go_604_0200 java Lego Mindstorm go_604_1000 java programming go_605_0000 javascript go_605_1000 javascript programming go_700_0000 ... go_701_0000 mysql go_701_0001 mysql: manage users go_701_0002 mysql: change the default collation go_701_0003 mysql: store encrypted login on file system go_701_0004 mysql: dump database go_800_0000 ... go_800_0010 raspberry pi raspi go_900_0000 misc ---:---:--- ---:---:--- ---:---:--- go_400_0000 ... ---:---:--- go_401_0050 Random ##random # get 12 random chars $ cat /dev/urandom | tr -cd 'a-zA-Z0-9.-' | head -c12 # get 12 random bytes $ cat /dev/urandom | head -c12 | base64 ---:---:--- go_401_0060 curl examples # curl silent but with errors $ curl --insecure --silent --fail --show-error https://spacetrack.github.io/invalid/file.txt # curl with HTTP response code on output $ curl --insecure --silent --write-out "%{stderr}HTTP/%{http_version} %{response_code}" https://spacetrack.github.io/invalid/file.txt ---:---:--- go_402_0000 crypto go_402_0100 openssl go_402_0110 encryption with openssl ##openssl ##encrypt ##decrypt # encrypt files $ set +o history $ tar -cvf - * | bzip2 -9 | openssl enc -aes-256-cbc -md sha512 -pbkdf2 -iter 100000 -salt -in - -out - -e -k "my-secret-passwd" | base64 > files.tar.bz2.enc.b64.txt $ set -o history # decrypt files $ set +o history $ cat files.tar.bz2.enc.b64.txt | base64 -d | openssl enc -aes-256-cbc -md sha512 -pbkdf2 -iter 100000 -salt -in - -out - -d -k "my-secret-passwd" | bzip2 -d | tar -xvf - $ set -o history # openssl shortcut $ cat > opensslpipe.sh << EOF #!/bin/bash openssl enc -aes-256-cbc -md sha512 -pbkdf2 -iter 100000 -salt -in - -out - \${1} -k \${2} EOF # encrypt/decrypt files $ set +o history $ tar -cvf - * | bzip2 -9 | opensslpipe.sh -e "my-secret-passwd" | base64 > files.tar.bz2.enc.b64.txt $ cat files.tar.bz2.enc.b64.txt | base64 -d | opensslpipe.sh -d "my-secret-passwd" | bzip2 -d | tar -xvf - $ set -o history # encrypt/decrypt (short) text $ set +o history $ echo 'a secret message' | opensslpipe.sh -e 'my-secret-passwd' | base64 $ echo 'U2FsdGVkX1+OdddqCYCobh5tJL0hvX7eO/c0wi10yNfbbs73jgzNfdLj/MFVgl2z' | base64 -d | opensslpipe.sh -d 'my-secret-passwd' $ set -o history ---:---:--- go_402_0120 run a web-server with openssl ##openssl ##tinywebserver # credits $ start https://www.devdungeon.com/content/one-line-http-servers # create a self-signed certificate (or get one from Let's Encrypt) $ openssl req -newkey rsa:2048 -nodes -keyout private-key.pem -x509 -days 365 -out certificate.pem # start the web server $ openssl s_server -key private-key.pem -cert certificate.pem -accept 8080 -WWW ---:---:--- go_402_0200 hashing go_402_0210 proof to be first author ##sha256 # store the text in static file $ vi hello-world.txt # hash the file $ sha256sum hello-world.txt 53ebf7070d1dd57254a317f4e3ca898f3a2ebc1c017ace73e707e096a29bdc51 *hello-world.txt # publish the resulting hash, e. g. on twitter or a blockchain ... curl -X POST 'https://api.twitter.com/1.1/statuses/update.json?status=hello' --header 'authorization: OAuth oauth_consumer_key="oauth_customer_key", oauth_nonce="generated_oauth_nonce", oauth_signature="generated_oauth_signature", oauth_signature_method="HMAC-SHA1", oauth_timestamp="generated_timestamp", oauth_token="oauth_token", oauth_version="1.0"' ---:---:--- go_403_0000 bash go_403_0010 bash: redirect stdin stdout stderr # credits $ start http://www.tldp.org/LDP/abs/html/io-redirection.html ---------------------------------------- 1>filename # Redirect stdout to file "filename." 1>>filename # Redirect and append stdout to file "filename." 2>filename # Redirect stderr to file "filename." 2>>filename # Redirect and append stderr to file "filename." &>filename # Redirect both stdout and stderr to file "filename." # This operator is now functional, as of Bash 4, final release. 2>&1 # Redirects stderr to stdout. # Error messages get sent to same place as standard output. >>filename 2>&1 # If redirecting both stdout and stderr, # the order of the commands makes a difference. ---------------------------------------- # redirect stdout to file1, stderr to file2, stdout + stderr to file3 $ { { echo "1 hello world"; (>&2 echo "2 hello error"); echo "3 hello world"; (>&2 echo "4 hello error"); } 1> >(tee stdout.log) 2> >(tee stderr.log >&2); } >> all.log 2>&1 # redirect stdout to mail 1, stderr to mail 2 $ { { echo "1 hello world"; (>&2 echo "2 hello error"); echo "3 hello world"; (>&2 echo "4 hello error"); } | mail -s "test stdout `date`" bwinkler@netmediaeurope.com; } 2>&1 | mail -s "test stderr `date`" bwinkler@netmediaeurope.com # redirect stdout to nothing, stderr to mail, stdout + stderr to file $ { { echo "1 hello world"; (>&2 echo "2 hello error"); echo "3 hello world"; (>&2 echo "4 hello error"); } 1> >(tee stdout.log) 2> >(tee /dev/stderr | mail -s "test stderr `date`" bwinkler@netmediaeurope.com); } >> all.log 2>&1 ---:---:--- go_403_0030 bash: multidimensional arrays # blog: how to simulate multidimensional arrays $ start https://spacetrack.github.io/blog/2016/bash-mehrdimensionale-arrays.html ---:---:--- go_404_0000 windows powershell go_404_0001 windows powershell: get version # get version of PowerShell > $PSVersionTable.PSVersion ---:---:--- go_404_0002 windows powershell: force to use UTF-8, ascii, ... # set char encoding in PowerShell version 5.1 or higher > $PSDefaultParameterValues['Out-File:Encoding'] = 'utf8' > $PSDefaultParameterValues['Out-File:Encoding'] = 'ascii' ---:---:--- go_404_0010 windows powershell: run command elevated # run command elevated (= as administrator), e. g. cmd > powershell -Command "Start-Process -Verb runAs cmd.exe" # run command elevated (= as administrator), e. g. create a Windows service > powershell -Command "Start-Process -Verb runAs sc.exe -ArgumentList 'create', 'MyService', 'BinPath=C:\temp\MyService.exe'" > & sc.exe query MyService ---:---:--- go_403_0020 bash: for loops $ for i in {0..9}; do echo $i; done $ for ((i=0;i<10;i++)){ echo $i;} $ for var in list; do command; done ---:---:--- go_404_0020 windows powershell: send e-mail # credits > start https://blog.mailtrap.io/powershell-send-email/ # send e-mail > Send-MailMessage ` -UseSsl ` -Credential (Get-Credential) ` -SmtpServer 'mail.gmx.net' ` -Port 587 ` -To 'bjoern.winkler+test-powershell@gmail.com' ` -From 'bjoern_winkler@gmx.de' ` -Subject 'test from powershell' ` -Body 'test from powershell' ---:---:--- go_404_0030 windows powershell: taskschd windows cron # credits > start https://blog.netwrix.com/2018/07/03/how-to-automate-powershell-scripts-with-task-scheduler/ # create new task from powershell > $Trigger = New-ScheduledTaskTrigger -At 4:00am –Daily > $User = "NT AUTHORITY\SYSTEM" > $Action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "C:\my-scripts\my-script.ps1" > Register-ScheduledTask -TaskName "MonitorGroupMembership" -Trigger $Trigger -User $User -Action $Action -RunLevel Highest –Force # create new task from powershell: one line! ;-) > Register-ScheduledTask -TaskName "Dump MySQL database" -Trigger $(New-ScheduledTaskTrigger -At 4:00am –Daily) -User "NT AUTHORITY\SYSTEM" -Action $(New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "C:\scripts\mysql-dump.ps1") -RunLevel Highest –Force # check if the daily task has been configured > Get-ScheduledTask | Select-String Dump # check if "NextRunTime" shows tomorrow, 4:00 am > Get-ScheduledTaskInfo -TaskName "Dump MySQL database" ---:---:--- go_404_0035 windows powershell: find file # find a file in a directory recursively > dir -recurse | Where-Object { $_.PSIsContainer } | Select FullName | convertto-csv ---:---:--- go_404_0040 windows powershell: find string in files (grep -r) # credits > start https://stackoverflow.com/a/8153857 # search a string in multiple files and return the names of files > Get-ChildItem -Recurse | Select-String "unsub" -List | Select Path ---:---:--- go_404_0041 windows powershell: get number of lines (wc -l) # get number of PDF files in a directory $ ls -la *.pdf | wc -l > dir *.pdf | Measure-Object -line ---:---:--- go_404_0045 windows powershell: URL encode / decode ##urlencode ##urldecode # powershell 5 URL encode/decode: > [uri]::EscapeDataString("hallo welt") > [uri]::UnescapeDataString("hallo%20welt") # powershell 6 URL encode/decode > [System.Web.HttpUtility]::UrlEncode("hallo welt") > [System.Web.HttpUtility]::UrlDecode("hallo+welt") ---:---:--- go_404_0046 windows powershell: BASE64 encode / decode # base64 encode > [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("hello world")) # base64 decode > [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String("aGVsbG8gd29ybGQ=")) ---:---:--- go_404_0050 windows powershell: GUID # create a new GUID > New-Guid # get string of new GUID > (New-Guid).Guid # send new GUID to clipboard > New-Guid | Set-Clipboard ---:---:--- go_410_0000 linux admin ---:---:--- go_410_0010 linux version # get version of ... $ : linux version :; cat /proc/version $ : ubuntu version :; lsb_release -a $ : centos version :; cat /etc/redhat-release $ : raspbian version :; cat /etc/os-release ---:---:--- go_410_0015 linux reboot needed # check if reboot is needed ... $ : ubuntu reboot needed :; test -e /var/run/reboot-required && echo 'yes, reboot required!' || echo 'no reboot needed' $ : centos reboot needed :; needs-restarting -r -s ---:---:--- go_410_0100 linux ubuntu resize partition # check all available or the specified block devices $ sudo lsblk # check free space $ sudo vgdisplay # increase size of partition $ lvresize -l +100%FREE /dev/ubuntu-vg/ubuntu-lv # increase size of file system $ resize2fs /dev/ubuntu-vg/ubuntu-lv # reboot $ sudo reboot ---:---:--- go_411_0000 windows admin go_411_0100 windows admin: listening to port # find exe that is listening to a port 5000 on Windows > netstat -abon | findstr 5000 > tasklist | findstr ---:---:--- go_420_0001 tmux ##tmux ##screen # tmux simple start $start https://www.sitepoint.com/tmux-a-simple-start/ $start https://gist.github.com/henrik/1967800 # new window: CTRL+b c # list windows: CTRL+b w # goto window: CTRL+b # detach session: CTRL+b d # split window (create panes) horizontal: CTRL+b % # split window (create panes) vertical: CTRL+b " # split window - swap panes: CRTL+b o # tmux list detached sessions $ tmux ls # tmux attache session $ tmux a # ---:---:--- go_421_0000 ssh go_421_0001 ssh: run an HTTP server on remote node and browse through local web # step 1: start a remote web server remote $ python3 -m http.server 25000 # step 2: start a local ssh session local $ ssh -L 8000:localhost:25000 id@remote -N # step3: start a local browser local $ start http://localhost:8000 ---:---:--- go_500_0000 ... ---:---:--- go_501_0010 FFMPEG ##ffmpeg # ffmpeg 12seconds $ ffmpeg -i MOV00199.avi -ss 00:00:09 flughafen.mpg $ ffmpeg -i 2008-trailer.avi -croptop 18 -cropbottom 18 -b 30000000 -ab 128 2008-trailer_540.mpg $ ffmpeg -i 2008-trailer_540.mpg -s 320x240 -b 400000 -ab 128 2008-trailer_320.mpg $ ffmpeg -i "H:20 Der dicke K?.avi" -acodec libmp3lame -ab 128k -ar 44100 -vcodec mpeg4 -b 512k -s 224x176 wickie-20-der-dicke-koenig.avi $ ffmpeg -i das_Schlossgespenst.mkv -s 320x240 -vb 400000 -ab 128000 c:das_Schlossgespenst.mpg $ ffmpeg -i 55_Wer_anderen_eine_Grube_graebt.avi -s 320x240 -vb 400000 -ab 128000 55_Wer_anderen_eine_Grube_graebt.mpg $ ffmpeg -i save-tv.avi -ss 00:06:52 -croptop 18 -cropbottom 18 -s 640x480 -vb 1000000 -ab 128000 ppc.mov $ ffmpeg -i vc2010_4970_Im_Blickfeld.avi -croptop 86 -cropbottom 86 -vb 1300000 -ab 128000 -ar 44100 vc2010_4970_Im_Blickfeld.mpeg $ ffmpeg -i vc2010_5011_Was_bringt_die_Zukunft.avi -vb 1300000 -ab 128000 -ar 44100 vc2010_5011_Was_bringt_die_Zukunft.mpeg $ ffmpeg -i vc2010_2917_vision2010-unbekannte-heimat.flv -vb 1300000 -ab 128000 -ar 44100 vc2010_2917_vision2010-unbekannte-heimat.mpeg $ ffmpeg -i vc2010_4878_Vision_2010_endv.wmv -s 580x326 -vb 1300000 -ab 128000 -ar 44100 vc2010_4878_Vision_2010_endv.mov $ ffmpeg -i TV-20090512-0448-1501.hi.flv -sameq -ss 00:03:12 -t 23 hubble-1.mpeg $ ffmpeg -i TV-20090519-1418-2201.hi.flv -sameq -ss 00:08:42 -t 24 hubble-2.mpeg $ cat hubble-1.mpeg hubble-2.mpeg > hubble-1-2.mpeg $ ffmpeg -i hubble-1-2.mpeg -sameq hubble.mpeg $ ffmpeg -i "06 No Tears Anymore.m4a" -ab 192000 "06 No Tears Anymore.mp3" $ ffmpeg -i "01 Speed of Sound.m4a" -ab 192000 "01 Speed of Sound.mp3" $ ffmpeg -i "16 21 Guns.m4a" -ab 192000 "16 21 Guns.mp3" $ ffmpeg -i "01 If a Song Could Get Me You.m4a" -ab 192000 "01 If a Song Could Get Me You.mp3" $ ffmpeg -i "08 Trouble Is a Friend.m4a" -ab 192000 "08 Trouble Is a Friend.mp3" $ ffmpeg -i "02 Locker macha (Explicit Lyrics).m4a" -ab 192000 "02 Locker macha (Explicit Lyrics).mp3" $ ffmpeg -i "02 Sweet About Me.m4a" -ab 192000 "02 Sweet About Me.mp3" $ ffmpeg -i "12 Mary's Boy Child.m4a" -ab 192000 "12 Mary's Boy Child.mp3" $ ffmpeg -i "E:\data-bjw\Music\iTunes\iTunes Music\Podcasts\Adam Curry's Daily Source Code\822 DSC-822-2010-03-19.mp3" -ab 192000 -ss 00:56:30 -t 480 dsc-822-beth-thornley.mp3 # 00:33:16 - 00:04:46 = 1710sec $ ffmpeg -i We_Love_in_Concert_a_ha_Foot_of_the_Mountain_2009-06-19_01-35_180137.avi -ss 00:04:46 -t 1710 -ab 128000 -vb 1200000 aha-1.m4v $ ffmpeg -i a_ha_Documentary_Foot_of_the_Mountain_2009-06-28_01-10_180137.avi -ss 00:05:30 -t 5130 -ab 128000 -vb 1200000 aha-2.m4v ---:---:--- go_501_0020 mstsc ##mstsc # credits $ start 'https://shortcutworld.com/Windows-Remote-Desktop/win/Windows-Remote-Desktop_Shortcuts' # start RDP session and connect to server > mstsc /v: # start RDP session in admin mode > mstsc /admin # useful shortcuts in a RDP session - Alt+Page Up | equals standard desktop Alt+Tab - Alt+Page Down | equals standard desktop Alt+Shift+Tab - Ctrl+Alt+Pause | toggle client between full-screen and window mode - Ctrl+Alt+Home | show connection bar when in full-screen mode - Ctrl+Alt+End | equals standard desktop Ctrl+Alt+Del ---:---:--- go_502_0000 haproxy go_502_0010 haproxy: validate config # validate haproxy configuration $ sudo haproxy -c -V -f /etc/haproxy/haproxy.cfg ---:---:--- go_503_0000 what is my ip address go_503_0020 what is my ip address: get external ip address # https://www.ipify.org/ $ curl -s 'https://api.ipify.org?format=json' go_590_0000 Azure go_590_0000 download attachments of Azure DevOps work item ---:---:--- go_590_0000 Azure ---:---:--- go_590_0001 download attachments of an Azure DevOps work item # install Azure DevOps extension > az extension add --name azure-devops # init Azure DevOps login, you need a Personal Access Token for that > az devops login # find the work item > az boards query --wiql "SELECT System.ID, System.Title, System.WorkItemType, System.AreaPath, System.AssignedTo, System.State from workitems order by System.ID asc" --organization https://dev.azure.com/YOUR-ORGANIZATION # download the attachments (PowerShell) > (az boards work-item show --id YOUR-WORK-ITEM-ID --organization https://dev.azure.com/YOUR-ORGANIZATION | ConvertFrom-Json).relations | Where-Object { $_.rel -eq "AttachedFile" } | ForEach-Object { Invoke-WebRequest $_.url -OutFile $_.attributes.name } ---:---:--- ---:---:--- ---:---:--- go_600_0000 ... ---:---:--- go_601_0000 git go_601_0010 git log: simple and well formatted # simple and well formatted git log output $ git log --pretty=format:'%C(yellow)%h %C(green)%as %C(reset)%s%C(red)%d' ---:---:--- go_601_0015 git tag: list tags in MAJOR-MINOR-PATCH-order # show git version tags in "correct" order as suggested by Semantic Versioning 2.0.0 (https://semver.org) $ git tag -l --format='%(tag) %(subject)' | tr - \\~ | sort -V | tr \\~ - ---:---:--- go_601_0020 git merge: dry run # test if master has been merged into current branch $ git merge --no-commit --no-ff master $ git diff --cached --name-only $ git diff --cached $ git merge --abort ---:---:--- go_602_0010 go(lang) in docker ##go ##golang # golang in docker (example 1) > docker run -i -t -v C:/projects/go:/go -p 8080:8080 --name golang golang > docker start -i golang $ go version $ go get github.com/golang/example/hello/... $ go run github.com/golang/example/hello $ go run github.com/golang/example/outyet $ export GOOS=windows GOARCH=amd64 $ go install github.com/golang/example/hello # golang in docker (example 2) > docker run --rm -v "%CD%:/usr/src/sendtoeds" -w /usr/src/sendtoeds -e GO -e GOOS=windows -e GOARCH=amd64 golang bash -c "go get -d -v ./... && go fmt && go build -v" > docker run --rm -i -t -v "%CD%:/usr/src/sendtoeds" -w /usr/src/sendtoeds -e GO -e GOOS=windows -e GOARCH=amd64 golang bash > docker run --rm -it -p 8080:8080 -v "%CD%:/usr/src/publisher" -w /usr/src/publisher -e GOOS=linux -e GOARCH=amd64 golang bash -c "go get -d -v ./... && go fmt && go run publisher.go -port=8080 -phob=0YAy.TaLp.SVTr -phan=XhfN.DQ35.4R4t" ---:---:--- go_603_0100 c# dotnet commands ##dotnetrun # .NET Command: format source code $ dotnet tool install -g dotnet-format $ dotnet format --dry-run --check $ echo $? > dotnet tool install -g dotnet-format > dotnet format --dry-run --check > Write-Host $LastExitCode ---:---:--- go_603_1000 c# dotnet programming go_603_1010 c# dotnet programming: Refresh ASP.NET Core MVC view without reloading the application # credits $ start https://dev.to/alexzeitler/refresh-asp-net-core-website-without-reloading-application-2ffo # add this NuGet package to the project: Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation $ dotnet add package 'Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation' # in Startup.cs change this line: <- `services.AddControllersWithViews();` -> `services.AddControllersWithViews().AddRazorRuntimeCompilation();` ---:---:--- go_604_0000 java go_604_0100 java commmands go_604_0200 java Lego Mindstorm ##mindstorm # Lego Mindstorm: first program > start http://www.lejos.org/nxt/nxj/tutorial/Preliminaries/FirstProgram.htm > nxjc HelloWorld.java > nxjlink -o HelloWorld.nxj HelloWorld > nxjupload -r HelloWorld.nxj > nxjc HelloWorld.java > nxj -r -o HelloWorld.nxj HelloWorld ---:---:--- go_604_1000 java programming ---:---:--- go_605_0000 javascript ---:---:--- go_605_1000 javascript programming ---:---:--- go_605_1000 javascript programming: sleep # credits $ start https://stackoverflow.com/a/39914235/13860643 # sleep for 5 seconds > await new Promise(r => setTimeout(r, 2000)); # sleep() function + demo ``` function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function demo() { console.log('taking a break for 5 seconds ...'); await sleep(5000); console.log('now showing sleep in a loop...'); for (let i = 0; i < 10; i++) { await sleep(2000); console.log(i); } } demo(); ``` ---:---:--- go_701_0000 mysql ## mysql ---:---:--- go_701_0001 mysql: manage users # list users > use mysql; > SELECT User, Host FROM user ORDER BY User; # create user > CREATE USER 'db_user'@'localhost' IDENTIFIED BY 'my.secret.password'; > CREATE USER 'db_user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'my.secret.password'; # (re)set password of user > SET PASSWORD FOR 'db_user'@'localhost' = 'yet.very.secret.password'; # change user > ALTER USER 'db_user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'my.secret.password'; # delete user > DROP USER 'microstaxx'@'localhost'; # show privileges > SHOW GRANTS FOR ticket_prd; # grant privileges > GRANT ALL PRIVILEGES ON app_db.* TO 'db_user'@'localhost'; > GRANT USAGE ON app_db.* TO 'db_user'@'localhost'; > GRANT SELECT, LOCK TABLES ON app_db.* TO 'db_user'@'localhost'; ---:---:--- go_701_0002 mysql: change the default collation # How to change the default collation (and default character set) of a database? $ start https://stackoverflow.com/questions/5906585/how-to-change-the-default-collation-of-a-database # change collation to latin1 > ALTER DATABASE app_db CHARACTER SET latin1 COLLATE latin1_german2_ci; # change database / tables to utf8 > use app_db; > ALTER DATABASE app_db CHARACTER SET utf8 COLLATE utf8_unicode_ci; > ALTER TABLE table_1 CHARACTER SET utf8 COLLATE utf8_unicode_ci; > ALTER TABLE table_2 CHARACTER SET utf8 COLLATE utf8_unicode_ci; > ALTER TABLE table_3 CHARACTER SET utf8 COLLATE utf8_unicode_ci; > ALTER TABLE table_4 CHARACTER SET utf8 COLLATE utf8_unicode_ci; > ALTER TABLE app_db.table_1 MODIFY colum_1 text CHARACTER SET utf8 COLLATE utf8_unicode_ci; ---:---:--- go_701_0003 mysql: store encrypted login on file system # set login (via cmd) > "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql_config_editor.exe" set --login-path db_user --host=db_host --user=db_user --password # set login (via powershell) > & 'C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql_config_editor.exe' set --login-path db_user --host=db_host --user=db_user --password # set login (via bash) $ mysql_config_editor set --login-path db_user --host=db_host --user=db_user --password # list all logins $ mysql_config_editor print --all # login to mysql $ mysql --login-path=db_user ---:---:--- go_701_0004 mysql: dump database # dump mysql database $ mysqldump -u root -p --skip-opt --default-character-set=utf8 --single-transaction --no-tablespaces --comments --hex-blob --dump-date --no-autocommit --add-drop-database --databases app_db > app_db-latest.sql # import exported data $ echo 'source app_db-latest.sql' | mysql -u root -p --default-character-set=utf8 app_db' ---:---:--- go_800_0010 raspberry pi raspi # (1) write image to SSD-card $ start https://www.raspberrypi.org/downloads/ # (3) on your raspi: change configuration # -> Localisation Options # ... set keyboard, time zone and Wifi to DE # -> Interface Options -> SSH # ... enable SSH $ sudo raspi-config ---:---:--- go_900_0000 misc