SQL

List databases and use the database ‘mydb’:

SHOW databases;
USE mydb;

List tables of the currently selected database:

SHOW tables;

Show ‘users’ table structure:

DESCRIBE users;

List the ‘username’ column of table ‘users’:

SELECT username FROM users;
SELECT MediaId,VolumeName FROM Media WHERE VolumeName='000797L4';

Update records:

UPDATE Media SET VolumeName = '000797L4' WHERE MediaId = 1201;

Create user:

create user user_name@localhost name identified by ‘pass_word’;

list users:

SELECT user, password, host FROM mysql.user;

change password:

SET PASSWORD FOR 'techonthenet'@'localhost' = PASSWORD('newpassword');

MySQL/MariaDB

mysqldump

mysql -u username -p database_name < file.sql

mysqldump bareos > /root/bareos.sql

load dump

mysql -p bareos < /root/bareos.sql

Show history:

more ~/.mysql_history