_                    _
  ___ | |__   __ _ _______ | |_
 / _ \| '_ \ / _` |_  / _ \| __|
| (_) | | | | (_| |/ / (_) | |_
 \___/|_| |_|\__,_/___\___/ \__|

MySQLusage and tips

show databases;
show tables;
show tables like '%pattern%'

Search for tables where the table name matches "users":

show tables like '%users%";

CREATE DATABASE <db_name>;
CREATE USER '<username>'@'localhost' IDENTIFIED BY '<password>' PASSWORD EXPIRE;
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
->   ON <db_name>.*
->   TO '<username>'@'localhost';

Create the user "user1" with the password "password1" on the database "db1":

CREATE DATABASE db1;
CREATE USER 'user1'@'localhost' IDENTIFIED BY 'password1' PASSWORD EXPIRE;
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
->   ON db1.*
->   TO 'user1'@'localhost';

(back to top)

Executing commands on mysql from a file.

$ cat <file> | sudo mysql

(back to top)

Use a SQL file to update database.

# mysql <database> < <file>.sql

(back to top)

Backup a database:

# mysqldump -p <database> > <file>.sql
The argument -p specifies a password, if not given, mysqldump prompts the user to enter a password.

# mysqldump <database> | gzip > <file>.sql.gz

(back to top)

Adding timezones to mysql:

$ mysql_tzinfo_to_sql /usr/share/zoneinfo | sudo mysql mysql

(back to top)

sql
VoidLinux manpages: mysql(1)
links
- MySQL
- MySQL - CREATE USER

(back to top)

2026-07-14 : Translated to Spanish.
  Added examples and improved format.
2026-03-24 : Created.

(back to top)

ohazot | about | ohazot.com <admin@ohazot.com>

This document applies to: linux , OpenBSD 7.8 | 2026-07-14