How can I access the MySQL command line with XAMPP for Windows?
To access MySQL in Windows you need to install the XAMPP.
Now go to the command prompt and open
C:\>cd xampp
C:\xampp>cd MySQL
C:\xampp\mysql>cd bin
C:\xampp\mysql\bin>mysql -h localhost -u root
Your database is now ready to be executed.
I had the same issue. Fistly, thats what i have :
xampp
and i have done this to fix my problem :
environnement variable
"%systemDrive%\xampp\mysql\bin\" C:\xampp\mysql\bin\
winpty mysql -u root
if your password is empty
or winpty mysql -u root -p
if you do have a passwordXampp control panel v2.3.1 I got errors while using -h localhost
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10060)
So, if you installed xampp as is and did not customize any documentroot, serverroot, etc. then the following works :-
start both the services on the xampp control panel click shell enter: # mysql -h 127.0.0.1 -u root
that works just fine. Below is the logtrail:-
# mysql -h 127.0.0.1 -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.21 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Shell
.mysql --user=your_user_name --password=your_password
.run xampp shell to solve connect to root using pw
mysql -h localhost -u root -p
and enter root pw
In terminal:
cd C:\xampp\mysql\bin
mysql -h 127.0.0.1 --port=3306 -u root --password
Hit ENTER if the password is an empty string. Now you are in. You can list all available databases, and select one using the fallowing:
SHOW DATABASES;
USE database_name_here;
SHOW TABLES
DESC table_name_here
SELECT * FROM table_name_here
Remember about the ";" at the end of each SQL statement.
Windows cmd terminal is not very nice and does not support Ctrl + C, Ctrl + V (copy, paste) shortcuts. If you plan to work a lot in terminal, consider installing an alternative terminal cmd line, I use cmder terminal - Download Page