On this page you find all important commands for the CLI tool mysql. If the
command you are looking for is missing please ask our AI.
mysql
MySQL is an open-source relational database management system (RDBMS). Its name is a combination of "My", the name of co-founder Michael Widenius's daughter My,[7] and "SQL", the acronym for Structured Query Language. A relational database organizes data into one or more data tables in which data may be related to each other; these relations help structure the data.
List of commands for mysql:
-
mysql:database:connect Connect to a database.$ mysql ${database_name}try on your machineexplain this command
-
mysql:database:connect:on:another:host Connect to a database on another host.$ mysql -h ${database_host} ${database_name}try on your machineexplain this command
-
mysql:database:connect:via-socket Connect to a database through a Unix socket.$ mysql --socket ${path/to/socket-sock}try on your machineexplain this command
-
mysql:database:connect:with-host Connect to a database on another host.$ mysql -h ${database_host} ${database_name}try on your machineexplain 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 machineexplain this command
-
mysql:database:create Create a new MySQL database$ mysql -u ${username} -e 'CREATE DATABASE ${database_name};'try on your machineexplain 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:databases:show This command will display all MySQL databases in the command-line interface.$ mysql -e 'SHOW DATABASES'try on your machineexplain 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 machineexplain this command
-
mysql:processlist:show Show all running processes for a given MySQL database$ mysql -e "show processlist;"try on your machineexplain 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 machineexplain 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 machineexplain 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 machineexplain this command
-
wordpress:database:create Create the database for the WordPress installation$ mysql -e "CREATE DATABASE ${database_name};" ${password};try on your machineexplain this command
-
wordpress:database:user:create Create the user (with permissions) a the WordPress installation$ mysql -e "CREATE USER '${username}'@'localhost' IDENTIFIED BY '${password}';GRANT ALL PRIVILEGES ON *.* TO '${username}'@'localhost' WITH GRANT OPTION;FLUSH PRIVILEGES;"try on your machineexplain this command