MySQL for System Administrators

LCA sysadmin miniconf
2021Jan23 @ 12:15
Melbourne

der.hans
CDE
Object Rocket, a rackspace company
https://www.ObjectRocket.com/

Yes, we’re hiring :)

Rackspace Technologies
https://rackspace.jobs/

Upcoming Presentations

LH_talks.qr.png

Social Media and Fediverse

resources/FLOX_advocate.Mastodon.qr.png

Default MySQL prompt

MySQL_prompt_default.png
MySQL_prompt_default.png

Oh the monotony!

2255673-agent_smith.jpg

Percolating Selzer

MYSQL_PS1

MYSQL_PS1 example

export MYSQL_PS1="(\u@\h:\d)> "
$ grep MYSQL_PS1 ~/.bashrc
export MYSQL_PS1="(\u@${HOSTNAME%.*.*}:\d)> "
$

MySQL shells, viva la difference

MySQL_prompt_wdb_LCA.png
MySQL_prompt_wdb_sonic_tools.png
MySQL_prompt_wdb_mysql_mel.png

Cluster to three

OpenSSH: the Home Game

OpenSSH_The_Home_Game.512x512.png

Non-automagic authentication

$ mysql -u root -p password

Interactive authentication

$ mysql -u root -p

Automagic authentication

Authorization / Privileges

Stored Procedures

SQL SECURITY

DEFINER

INVOKER

mysqldump

Use for schema dumps

Include mysql.proc to preserve routine creation timestamps

--no-data –routines –skip-add-locks –skip-opt --triggers –all-databases

Percona XtraBackup

Cool tool, still uses a lot of resources

Snapshots

Put MySQL data on snapshotable filesystem

Snapshot still requires short read-lock

mylvmbackup works with LVMv2

Log files

/var/log/mysql/

Querying Data

Use the tools we know

Build your own pipeline

e8d1_dr_who_build_your_own_sonic_screwdriver.400x501.jpg

Use your favorite CLI tools

sed | grep | awk | cut | sort | uniq

Sysadminny examples

find horsey music
$ mysql -e "select album from music" | grep -i horse
show root authorized from other than localhost
$ mysql -B -e "select user, host from mysql.user" | awk '$1 == "root" && $2 !~ /localhost|127.0.0.1|::1/'
as of 8.0.22, was something else before
$ mysql -e "show replica status\G" | grep -E 'Master_Host|Slave_.*_(State|Running)|Seconds_Behind_Master|Last_.*_Err'

libreadline

mysql> pager less

DB stuff

Character sets

Always specify character set when creating a DB or table

Or get used to Swedish

Community

Resources

Thank You

Credits

Thanks to the LCA organizers and other volunteers for running a conference for us to enjoy

Thanks to the FLOSS database community in its many forms

Thanks to Brian for the Open SSH Home game image

Thanks to OpenBSD and OpenSSH for that critical tool

Mahlzeit!