Quick login to Mysql on Ubuntu
If you prefer to login or run commands on the command line without supplying the Mysql username, password and host, you can store those details put a file that Mysql will read by default when it is called - here:
Create the file in your favourite editor.
Add the following content (adjust for YOUR user.)
[mysql] user=YOURUSER password=YOURPASS host=127.0.0.1 [mysqldump] user=YOURUSER password=YOURPASS host=127.0.0.1
Set the file permissions:
chmod 600 ~/.my.cnf
Now you can login to Mysql using:
Or dump a database with:
mysqldump --all-databases --single-transaction --events --routines --triggers | gzip > ./all_databases.sql.gz
If you provision with Ansible, Chef or Puppet, you can generate this file for each of your server users or deployers using secure vault encryption for transmission to server. Be sure to follow best practice security if you do it this way.