用cmd方式登陆mysql
输入如下命令: [code="sql"]mysql -h localhost -u root -p root -D test[/code]
为什么总是返回 unknown database 'root' ?
如果用gui工具添加root数据库则能够登陆
如果不加-D 参数则也只在有root数据库时才能登陆。
看来-D 参数没有起作用。。。不知为何。。求各位指教
抱歉,这个不是\h就能看到的
http://dev.mysql.com/doc/refman/5.0/en/mysql-command-options.html
或者在linux下面
[quote]$man mysql[/quote]
你可以看到
[quote]The password to use when connecting to the server. If you use the
short option form (-p), you cannot have a space between the option
and the password.[/quote]
[color=red]password与-p之间不能有空格[/color]
--database=db_name, -D db_name
The database to use. This is useful primarily in an option file.
[quote]如果不加-D 参数则也只在有root数据库时才能登陆。
看来-D 参数没有起作用。。。不知为何。。求各位指教[/quote]
不是的,你看
$ mysql -h localhost -u saarixx -psaarixx -D demo
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 54
Server version: 5.1.49-1ubuntu8.1 (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> exit;
授人以鱼不如授人以渔
mysql> 'help;' or '\h'
看看 -D 是什么