Monthly Archives: March 2021

mysql export users and passwords to another server

mysqldump migrate users to new server


MySQL 5.6 and older

while read line; do mysql -B -N -e "SHOW GRANTS FOR $line"; done < <(mysql -B -N -e "SELECT CONCAT('\'', user,'\'@\'', host, '\'') FROM user WHERE user != 'debian-sys-maint' AND user != 'root' AND user != ''" mysql) | sed 's/$/;/' > mysql_all_users_grants.sql

if MySQL 5.7 and above

while read line; do mysql -B -N -e "SHOW CREATE USER $line"; done < <(mysql -B -N -e "SELECT CONCAT('\'', user,'\'@\'', host, '\'') FROM user WHERE user != 'mysql' AND user != 'root' AND user != ''" mysql) | sed 's/$/;/' > mysql_create_users.sql

while read line; do mysql -B -N -e "SHOW GRANTS FOR $line"; done < <(mysql -B -N -e "SELECT CONCAT('\'', user,'\'@\'', host, '\'') FROM user WHERE user != 'mysql' AND user != 'root' AND user != ''" mysql) | sed 's/$/;/' > mysql_all_users_grants.sql

Excludes some users like root

connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80

Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). – connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). – connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out
Err:7 http://archive.ubuntu.com/ubuntu bionic-updates InRelease

echo "Acquire::ForceIPv4 "true";" > /etc/apt/apt.conf.d/99force-ipv4

wireguard 2 interfaces not workig

vim /etc/wireguard/wg0.conf

[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = WG0_SERVER_PRIVATE_KEY
SaveConfig = false

[Peer]
# client1
PublicKey = PUBKEY_FROM_CLIENT_ONE
AllowedIPs = 10.0.0.2/32

vim /etc/wireguard/wg1.conf

[Interface]
Address = 10.0.1.1/24
ListenPort = 51821
PrivateKey = WG1_SERVER_PRIVATE_KEY
SaveConfig = false

[Peer]
# client2
PublicKey = PUBKEY_FROM_CLIENT_TWO
AllowedIPs = 10.0.1.2/32

systemctl start wg-quick@wg0
systemctl start wg-quick@wg1