When you log into MySQL at CLI, you have to define the username and password

mysql -uusername -ppassword [database]

You can add these to a config file (.my.cnf) in the users home directory

vim ~/.my.cnf

and add these lines (changing the user and password of course)


and then you jus need to type

mysql [database]

and you are in.

You can even define the database and other settings with some extra lines…



Note: the file ~/.my.cnf is a user specific login file. If you want all users to be able to login with these credentials, you can edit the global /etc/my.cnf file instead.

Leave a comment

Your email address will not be published. Required fields are marked *