Examples of useful commands to use on MySQL CLI(Command-Line Interface)Last updated:
Show tables in a database
mysql> show tables;
Show a table's structure
mysql> describe <tablename>;
Load (execute) an sql file for the current database
If you have, for instance, an sql file full of inserts located in
/tmp/inserts.sql, you can import it to your database using the
mysql> source /tmp/inserts.sql;
Inserting/updating encrypted data
If you store sensitive data using encryption (as you should), you have probably sometimes wished you could set encrypted values into the database (for those times when you need to manually edit stuff in the database). For those times you can use mySQL Cryptographic Functions.
HEADS-UP Even when using strong hash algorithms (like SHA512), your password can still be cracked if you use common words that can be found in a dictionary.
-- set johndoe's password to 'mypassword' using SHA2-512 encryption update users set password = SHA2(512,'mypassword') where username='johndoe';