How to Access MySQL Command Line in XAMPP?

MySQL binaries should be under your XAMPP folder. Look for a /bin folder, and you’ll find the mysql.exe client around. Let’s assume it is in e:\xampp\mysql\bin, then you should fireup a command prompt in this folder.

First, go to e:\xampp, and run xampp_start. If you do not run xampp_start first, the error message “Can’t connect to Mysql server on ‘localhost'” will occur when you go to step 2.

Afer you run the commend prompt of DOS, then enter:

cd d:\xampp\mysql\bin
mysql.exe -u root –password

Enter password:
and enter root password

mysql>

After log into your mysql server, and start typing your commands.
Type “quit”  or “exit” to exit mysql

If you forgot mysql root password, what to do then? You can change root password as follows:

1. Stop running mysql;
2. Creat a .txt file, say “newrootpassword.txt”, enter the content:
SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘MyNewPassword’);
Save the file under F:
3. Run DOS commnad prompt  line:
C:\> F:\mysql\bin\mysqld-nt –init-file=F:\newrootpassword.txt

4. Run mysql, and stop it. Your new myslq root password will be OK.