mysql
TLDR
Connect to database
$ mysql -u [username] -p [database]
Connect to remote host$ mysql -h [hostname] -u [username] -p [database]
Execute SQL command$ mysql -u [user] -p -e "[SELECT * FROM table]" [database]
Execute SQL file$ mysql -u [user] -p [database] < [script.sql]
Connect with specific port$ mysql -h [host] -P [3306] -u [user] -p
Import database dump$ mysql -u [user] -p [database] < [dump.sql]
SYNOPSIS
mysql [options] [database]
DESCRIPTION
mysql is the MySQL command-line client. It connects to MySQL/MariaDB servers.
The tool executes SQL queries. Provides interactive and batch modes.
mysql is MySQL CLI client.
PARAMETERS
DATABASE
Database name.-h HOST
Server hostname.-u USER
Username.-p [PASSWORD]
Password (prompts if empty).-P PORT
Port number.-e COMMAND
Execute SQL and exit.--help
Display help information.
CAVEATS
Requires server access. Password prompt recommended. Beware SQL injection in scripts.
HISTORY
mysql was created as the standard CLI for MySQL database, maintained by Oracle and the community.
SEE ALSO
mysqladmin(1), mysqldump(1), mycli(1)


