Reset the MySQL Root Password
By default, the MySQL installation that ships with XAMPP has an empty root password. This is a serious security risk, especially if you plan to use XAMPP in production scenarios.
To change the MySQL root password, follow these steps:
Use the
mysqladmin
command-line utility to alter the MySQL password, using the following syntax:
mysqladmin --user=root password "newpassword"
The
mysqladmin
command-line utility is located within the
bin/
subdirectory of the XAMPP installation directory, typically
/opt/lampp
.
For example, to change the MySQL root password from its default empty value to the password
gue55me
, you would execute:
/opt/lampp/bin/mysqladmin --user=root password "gue55me"
Test that your password change has been accepted, by attempting to connect to the MySQL server using the
mysql
command-line client in the same directory. For example, you could use the command below to connect to the server and return the results of a calculation:
/opt/lampp/bin/mysql --user=root --password=gue55me -e "SELECT 1+1"