mysql连接配置文件配置文件

时间:2011-09-28 08:01:24

标签: mysql linux

有没有办法将连接参数(如主机,端口,用户名,密码,db)保存到我经常以快捷方式访问的mysql服务器上?

我正在为ubuntu中的终端寻找类似于ssh config的mysql的东西。优选地还具有ssh隧道支撑。

1 个答案:

答案 0 :(得分:0)

您可以将--defaults-file选项与shell别名结合使用, 例如:

% cat db01
[mysql]
user=root
password=<your_pwd>
host=<your_host>


% alias my_db01='mysql --defaults-file=db01'

% my_db01
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 41
Server version: 5.1.54-1ubuntu4 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

因此,您可以使用不同的设置创建不同的文件。

相关问题