mysql -h hostname -p -u user yourdatabase 在一本mysql书里这么写道: -u user_name (alternative form: --user=user_name)Your MySQL username. If you're using Unix and your MySQL username is the same as your login name, you can omit this option; mysql will use your login name as your MySQL username.Under Windows, the default username is ODBC, which is unlikely to be a useful default for you. Either specify a -u option on the command line, or add a default to your environment by setting the USER variable. For example, you can use the following set command to specify a username of sampadm:C:\> set USER=sampadmIf you place this command in your AUTOEXEC.BAT file, it takes effect whenever you start up Windows and you won't have to issue it at the prompt.
我找到好的方法了如果你在windows下操作 可以这样: 1、在c:/windows目录下建立一个my.ini的文件,在这个文件中加上以下内容: [client] host=yourhostname user=yourusername password=yourpassword database=yourdatabase这样就可以打开mysql就直接进入了你的数据库了 我试过的可以的。如果在unix下,Under Unix, you set up an option file by creating a file named ~/.my.cnf (that is, a file named .my.cnf in your home directory).里面的内容一样。 参考这本书的 MySQL™ The definitive guide to using, programming, and administering MySQL 4.1 and 5.0 Third Edition By Paul DuBois
在一本mysql书里这么写道:
-u user_name (alternative form: --user=user_name)Your MySQL username. If you're using Unix and your MySQL username is the same as your login name, you can omit this option; mysql will use your login name as your MySQL username.Under Windows, the default username is ODBC, which is unlikely to be a useful default for you. Either specify a -u option on the command line, or add a default to your environment by setting the USER variable. For example, you can use the following set command to specify a username of sampadm:C:\> set USER=sampadmIf you place this command in your AUTOEXEC.BAT file, it takes effect whenever you start up Windows and you won't have to issue it at the prompt.
可以这样:
1、在c:/windows目录下建立一个my.ini的文件,在这个文件中加上以下内容:
[client]
host=yourhostname
user=yourusername
password=yourpassword
database=yourdatabase这样就可以打开mysql就直接进入了你的数据库了
我试过的可以的。如果在unix下,Under Unix, you set up an option file by creating a file named ~/.my.cnf (that is, a file named .my.cnf in your home directory).里面的内容一样。
参考这本书的
MySQL™ The definitive guide to using, programming, and administering MySQL 4.1 and 5.0 Third Edition
By Paul DuBois
http://sharespot.flazx.net/download/0672326736.zip.htm
下载
这个网址不错我觉得