终端中快捷登录 MySQL
10 January, 2014
以前在终端中登录MySQL,需要输入这么长的一堆命令。
> mysql -u root -p
> please enter your password
> ******
在用户的根目录下添加了一个文件后,我只需要输入mysql,就可自动登录了。
> mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 100
Server version: 5.6.10 Source distribution
mysql>
怎么实现?
-
创建~/.my.cnf
-
将权限修改为 600
-
文件内容
[mysql]
user=root
password=pass
host=localhost[mysqldump]
user=root
password=pass
host=localhost[mysqldiff]
user=root
password=pass
host=localhost
参考资料: