_ _ ___ | |__ __ _ _______ | |_ / _ \| '_ \ / _` |_ / _ \| __| | (_) | | | | (_| |/ / (_) | |_ \___/|_| |_|\__,_/___\___/ \__|
| ohazot | docs | links | dev | conf | txt |
| es | > en < |
| mdoc file |
| search |
MySQL —
usage and tips
COMMANDS
show databases; show tables; show tables like '%pattern%'
example
Search for tables where the table name matches "users":
show tables like
'%users%";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';
example
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';
EXECUTE
Executing commands on mysql from a file.
$ cat <file> | sudo
mysqlREAD
Use a SQL file to update database.
# mysql <database> <
<file>.sqlBACKUP
Backup a database:
# mysqldump -p <database> >
<file>.sqlCompress backup
# mysqldump <database> | gzip
> <file>.sql.gzTIMEZONES
Adding timezones to mysql:
$ mysql_tzinfo_to_sql
/usr/share/zoneinfo | sudo mysql mysqlSEE ALSO
| sql |
| VoidLinux manpages: mysql(1) |
| links |
| - MySQL |
| - MySQL - CREATE USER |
HISTORY
| 2026-07-14 | : Translated to Spanish. |
| Added examples and improved format. | |
| 2026-03-24 | : Created. |