LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

mysql

command-line client

TLDR

Connect to database
$ mysql -u [username] -p [database]
copy
Connect to remote host
$ mysql -h [hostname] -u [username] -p [database]
copy
Execute SQL command
$ mysql -u [user] -p -e "[SELECT * FROM table]" [database]
copy
Execute SQL file
$ mysql -u [user] -p [database] < [script.sql]
copy
Connect with specific port
$ mysql -h [host] -P [3306] -u [user] -p
copy
Import database dump
$ mysql -u [user] -p [database] < [dump.sql]
copy

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.

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.

INSTALL

sudo apt install mariadb-client-core
copy
sudo dnf install mysql
copy
sudo apk add mariadb-client
copy
sudo zypper install mariadb-client
copy
brew install mysql
copy

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), mariadb(1), psql(1), sqlite3(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid