A Handy List of MySQL Commands

As with anything in our work we find the command line more efficient over time. Here is a good list of MySQL Commands which are easily forgotten in the day-to-day, like:

  • View a table's field descriptions
  • Creating new users and assigning database privileges
  • Dump databases to backup files
  • Dump a table to file
  • Restore a database or table from backup

Here are two handy commands that aren't on the list:

1) Temporarily disable foreign key constraints:

SET FOREIGN_KEY_CHECKS=0;

Be sure to perform SET FOREIGN_KEY_CHECKS=1; afterward.

2) Change the current count of an AUTO_INCREMENT value:

ALTER TABLE t2 AUTO_INCREMENT = value;

Posted April 05, 2017 02:56 PM EDT

More Like This Post