Linux Commands Helper
💬 Your AI-powered Linux assistant
mysql Command - MySQL Database Client
The mysql command is a command-line client for MySQL and MariaDB databases. It allows you to connect to a database server, run SQL queries, and manage databases interactively or via scripts.
Syntax
mysql [options] [database]
Examples
mysql -u root -p
Connect to MySQL as the root user and prompt for a password.
mysql -h 192.168.1.10 -u user -p mydb
Connect to the 'mydb' database on a remote server.
mysql -e "SHOW DATABASES;"
Run a SQL command directly from the shell.
Notes
- mysql is commonly used for database administration, scripting, and troubleshooting.
- Use
mysqlbinlog
to process binary log files generated by the MySQL server. - For backups, consider using
mysqldump
(if available on your system).