Page 1 of 1

How to access MySQL command line?

PostPosted: 08. August 2008 18:16
by Galdhrim
How can I access the mysql console? I have tried from windows command prompt, but it refuses to let me in...

PostPosted: 08. August 2008 21:36
by Nobbie
What did you try exactly?

PostPosted: 11. August 2008 08:25
by Galdhrim
I don't remember details now, I had posted this question in a thread, and that was several days ago...

But I went to windows XP command console, and tried something like:

"mysql.exe -user pass" or something like that. Please note that I don't remember now the name of the exe file, and I don't remember the options I tried to use. At first, I tried without providing a password, and it said "wrong password". When I provided a password, it said something like "refused connection"... I looked at the commands provided by -help option (or maybe it was /option or -h... I really can't remember that now), but I couldn't discover the right way to do it.

I was used to be asked for my password and nothing more, when I used WampServer...

PostPosted: 11. August 2008 11:57
by Nobbie
To enter the command line mode you must enter this command in a cmd:

Code: Select all
mysql --user=username --password=passwd database


where "username" is a valid MySQL User, "passwd" is the password of "username" and "database" is a valid Database in MySQL.

If you like to connect to a server different from the localhost, you may also apply a different host:

Code: Select all
mysql --user=username --password=passwd --host=hostname database

PostPosted: 11. August 2008 16:12
by Galdhrim
Nobbie wrote:To enter the command line mode you must enter this command in a cmd:

Code: Select all
mysql --user=username --password=passwd database


where "username" is a valid MySQL User, "passwd" is the password of "username" and "database" is a valid Database in MySQL.



I see... my mistake was to not use the --password= option... now I remember I provided the user in the right way, but I just put a blank space an my password... also, I didn't enter the name of the database. In Wampserver, I had to login first, and the use the "use" command to enter the database name...

Thanks for your reply, I intend to keep using Xampp (because of the portability of non-install version, it can run in not default ports, and it has a lot of interesting addons), so being able to use mysql command line mode is really important.

Thanks again.

PostPosted: 11. August 2008 21:38
by Nobbie
>In Wampserver, I had to login first, and the use the "use" command to enter the database name...

This works also, you need not to specify a database name on the command line (it's optional). I simply recommend it for ease of use.