0%

Problems about setting up DVWA on wsl-kali

Problems

  1. Response code 500 on localhost/dvwa

    There may be some requried php module not being installed. Check all php module status in localhost/dvwa/setup.php

    In my cases, the PHP module mysql is not installed, and I’m solving this by:

    1
    2
    sudo apt-get install php-mysql
    sudo service apache2 restart
  2. Error message: Stopping MariaDB database server: mysqld failed!

    This may be caused by the changes of mysql’s root password. A detailed explaination is found here

    Why this is happening

    This is a common problem if you do a mysql import and overwrite the mysql database itself, such as when you might be restoring from a mysqldump -A backup.

    This is a good thing: you probably want to back up all your mysql users, permissions, etc – but it can wreak havoc with things like the debian-sys-maint user used to cleanly shutdown mysql.

    Although this new database will possibly change both the root password and the debian-sys-maint password, of course it won’t automatically change the expected debian-sys-maint password in /etc/mysql/debian.cnf. In fact, unless you also backed up that file, you probably don’t even know what that password is anymore!

    Resetting the mysql root password (optional)

    First things first. If the mysql root password was different between old and new servers, you can use mysqladmin to fix it:
    mysql -p -u root password 'newpassword'

    However, when you apt-get installed mysql-server, it probably prompted you for the new mysql root password and you probably used the same one that you were using from before.

    Fix the debian sys maint password

    So now look up the debian sys maint password that debian created for you when you installed it on the new server. (You need sudo because this should be a highly protected file.)
    sudo cat /etc/mysql/debian.cnf

    Now, log in to mysql using the root password you set above:
    mysql -p -u root # use your new password when prompted

    Reset the password for the debian-sys-maint user and don’t forget to flush privileges:

    1
    2
    3
    SET PASSWORD FOR 'debian-sys-maint'@'localhost' = PASSWORD('samepassword');
    FLUSH PRIVILEGES;
    QUIT

    Test to be sure it works:
    sudo /etc/init.d/mysql restart

    Quick tip

    If you ever need to reset the root password for the server without having to bring down the server, this user account has the authority to do it – just cat the debian.cnf file and log in with that user. N.B. Protect this user account just like root.