Some handy commands for MySQL:

  • mysql -u root -p
    • will login to mysql as root and prompt for the password
  • show databases;
    • will list the databases that exist
  • use databasename;
    • Switches to the database name
  • show tables;
    • lists the tables in the database
  • quit;
    • exit
  • mysqldump -u root -p --opt > /tmp/databases.sql
    • Dump all databases to a file which can be imported later
  • mysqldump -u root -p --databases databasename > /tmp/databasename.sql
    • Dump a certain database to a file to be imported later
  • mysql -u root -p -h localhost databasename < “/tmp/databasebackup.sql”
    • Import a file into a database
  • UPDATE user SET password=PASSWORD(‘YourPasswordHere’) WHERE User=’root’ AND Host = ‘localhost’;
    • change password

Reference: http://www.zbeanztech.com/blog/important-mysql-commands

https://www.tecmint.com/change-mysql-mariadb-root-password/