12

How do I create a new MySQL user in XAMPP? Also, can I delete the existing “root” user?

TRiG
  • 10,148
  • 7
  • 57
  • 107
Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551

3 Answers3

10

It's too late but I'm sure my answer will help the community.

  1. To create a new mysql user in XAMPP you need to type the following commands:
mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';
\q

This command grants the user all permissions.For more information about setting MySQL database permissions, please visit https://dev.mysql.com/doc/refman/5.5/en/grant.html.

  1. To delete MySql user definitively you should run this command
DELETE FROM mysql.user 
WHERE  user = 'root' 
     AND host = 'localhost';

Hope that it's helpful.

Félix Maroy
  • 1,389
  • 2
  • 16
  • 21
0

XAMPP

sudo /opt/lampp/bin/mysql -u root -p

Enter Your Super Secret Password

CREATE USER 'UserName'@'localhost' IDENTIFIED BY 'UR@Secret@Password';

GRANT ALL PRIVILEGES ON * . * TO 'UserName'@'localhost';

FLUSH PRIVILEGES;

Native MySQL Client (Not XAMPP / LAMPP)

sudo mysql -u root -p

Enter Your Super Secret Password

CREATE USER 'UserName'@'localhost' IDENTIFIED BY 'UR@Secret@Password';

GRANT ALL PRIVILEGES ON * . * TO 'UserName'@'localhost';

FLUSH PRIVILEGES;

-1

For me below configuration worked. Its for LAMPP:

-Create a new database named "dvwa" from http://localhost/phpmyadmin/index.php.

-And then inside DWVA nano config.inc.php file. Make "db_password field" empty. (ex. '').

-restart the apache as well as mysql from xampp

adarsh kavtiyal
  • 55
  • 1
  • 10