Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect from windows command prompt to mysql command line

I'm trying to connect to mysql server command line from my windows prompt

I write the next line in cmd but i get an error.

cd C:\MYSQL\bin\ 

And then i execute

mysql.exe -u=root -p=admin 

but i getting this error

ERROR 1045: <28000>: Access denied for user 'root'@'localhost' <using password:YES> 

Thanks,

like image 730
Washu Avatar asked Dec 06 '12 20:12

Washu


People also ask

How do I run MySQL from command line?

Launch the MySQL Command-Line Client. To launch the client, enter the following command in a Command Prompt window: mysql -u root -p . The -p option is needed only if a root password is defined for MySQL. Enter the password when prompted.

What is the client for MySQL to connect from command prompt?

The mysql command-line client is typically located in the bin directory of the MySQL's installation folder. If the mysql program is already in the PATH , you can simply invoke it using mysql command. -u root means that you connect to the MySQL Server using the user account root .


1 Answers

The cd in your question is invalid (quoting it here because you've removed it once, and it was there when this answer was posted):

cd CD:\MYSQL\bin\ 

You can't cd to CD:\ anything, because CD:\ isn't a valid directory in Windows. CD: would indicate a drive, except that drives are restricted to a single letter between A and Z.

If your \MYSQL\BIN is on drive C:, then your commands need to be:

C:\>cd \MYSQL\Bin C:\MYSQL\Bin>mysql -u root -p admin 

If you're not already on C: (which you'll know by looking at the prompt in the cmd window), or your MySQL folder is on another drive (for instance, D:), change to that drive too:

C:\> cd /d D:\MYSQL\Bin D:\MYSQL\Bin>mysql -u root -p admin 

The .exe after mysql is optional, since .exe is an executable extension on Windows. If you type mysql, Windows will automatically look for an executable file with that name and run it if it finds it.

Note that in both my examples of running mysql, there are no = signs. You should just use -p with no password, and wait to be prompted for it instead.

like image 76
Ken White Avatar answered Oct 12 '22 05:10

Ken White