Forrest logo
back to context overview

mysql

List of commands for mysql:

  • mysql:database:connect Connect to a database.
    $ mysql ${database_name}
    try on your machine
    explain this command
  • mysql:database:connect:on:another:host Connect to a database on another host.
    $ mysql -h ${database_host} ${database_name}
    try on your machine
    explain this command
  • mysql:database:connect:via-socket Connect to a database through a Unix socket.
    $ mysql --socket ${path/to/socket-sock}
    try on your machine
    explain this command
  • mysql:database:connect:with-host Connect to a database on another host.
    $ mysql -h ${database_host} ${database_name}
    try on your machine
    explain this command
  • mysql:database:connect:with-password Connect to a database, user will be prompted for a password.
    $ mysql -u ${user} --password ${database_name}
    try on your machine
    explain this command
  • mysql:database:create Create a new MySQL database
    $ mysql -u ${username} -e 'CREATE DATABASE ${database_name};'
    try on your machine
    explain this command
  • mysql:database:dump:with-progress-bar Import a MySQL dump with progress bar into a MySQL server
    $ pv ${mysql_dump_path} | mysql -u ${username} -p ${database_name}
    try on your machine
    explain this command
  • mysql:database:import-dump Restore a dump file from a mysqldump
    $ mysql -u ${user} -p < ${dump_filepath}
    try on your machine
  • mysql:database:import:import-file Import a SQL file into a MySQL server
    $ mysql -u ${username} -p ${database_name} < ${sql_filepath}
    try on your machine
  • mysql:database:schema:export:without-data Export MySQL database schema without exporting its data
    $ mysqldump -h ${host_name_or_ip} -u ${username} -p --no-data dbname > ${output_sql_file_path}
    try on your machine
    explain this command
  • mysql:databases:show This command will display all MySQL databases in the command-line interface.
    $ mysql -e 'SHOW DATABASES'
    try on your machine
    explain this command
  • mysql:install Install a MySQL database server.
    $ apt-get install mysql-server
    try on your machine
    explain this command
  • mysql:logs:binary:purge:interval Remove all binary logs that are older than a given interval (in days).
    $ mysql --execute "PURGE BINARY LOGS BEFORE NOW() - INTERVAL ${interval_in_days} DAY"
    try on your machine
    explain this command
  • mysql:processlist:show Show all running processes for a given MySQL database
    $ mysql -e "show processlist;"
    try on your machine
    explain this command
  • mysql:tldr:4c6d2 mysql: Restore all databases from a backup (user will be prompted for a password).
    $ mysql --user ${user} --password < ${path-to-backup-sql}
    try on your machine
    explain this command
  • mysql:tldr:58b37 mysql: Execute SQL statements in a script file (batch file).
    $ mysql -e "source ${filename-sql}" ${database_name}
    try on your machine
    explain this command
  • mysql:tldr:63de1 mysql: Restore a database from a backup created with `mysqldump` (user will be prompted for a password).
    $ mysql --user ${user} --password ${database_name} < ${path-to-backup-sql}
    try on your machine
    explain this command
  • mysql:user:root:change-password Change the mysql root password
    $ mysqladmin -u root -p password ${newPassword}
    try on your machine
    explain this command
back to context overview