How to quick login to Mysql on Ubuntu command line

Login or run commands on the command line without supplying the Mysql username, password & host - no GUI


Create the file in your favourite editor.

vim ~/.my.cnf

Add the following content (adjust for YOUR user.)



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.

a web designers face on a laptop screen

Schedule a free call -we'd love to talk about your web design project

We'll talk for around 10 minutes on phone or video about what you're looking to do. Free, no sales.

Leed's web design - transform your business

We help you imagine, create, market and evolve an effective digital presence for your business or brand. Leveraging creative technology to deliver high performance, cost effective digital marketing and design.

Leeds Local Business: Exploring ideas together