SQL Injection Fundamentals - mysql is not a valid command

The module is wanting me to connect to a mysql database. I know the command but every I try to run mysql plus the flags, it comes up and says that mysql is not a valid command.

Can’t seem to install mysql/mariadb either. Thoughts on how to get past this or what I need to do to call mysql?

I am not very clear about your description, can you be more detailed? (It’s best to have pictures)

Yeah sorry about that.

The question is

Connect to the database using the MySQL client from the command line. Use the ‘show databases;’ command to list databases in the DBMS. What is the name of the first database?

The command should be mysql -u root -h target.IP.address -P 31475 -p but when I try to use that command it tells me gives me the error:

bash: mysql: command not found

I’ve tried installing it with sudo apt install mariadb-server but it can’t find the package. I also ran sudo apt upgrade prior to trying to install it

And…it just finally installed. What I did to fix it was made sure that all packages were updated. Apparently it had missed 2 in the update process. I then ran sudo apt install mariadb-server-10.3 and it went through.

Total user error on this one.

I have a similar issue in the module ‘SQL Injection Fundamentals.’ When I try to open MySQL in my Pwnbox I get the reponse that MySQL is not a valid command. I ran sudo apt update and sudo apt install mariadb-server-10.3. I try to start MySQL but I get the error “ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)”.

Update - Solved my issue by doing the following:
sudo apt update
sudo apt install mariadb-server-10.3
service mysql start (For password I used the one assigned to me using my personal Pwnbox on the HTB website.)
sudo mysql

How to do this using the default Pwnbox instance in the academy I don’t know, but using it with your own personal Pwnbox instance works no problem.

Guys, i am having the same problem. I tried the above solution from ObfusScape
but i cant execute “service mysql start” the provided password (password) does not work.
Also, what is the right command to connect to MySQL?

Are you running the mysql command with sudo??
should be
sudo mysql -u root -p -h your.ip.address.here -P portnum

It’s not working. I’m struggling with the same issue. I have been able to connect only once, one week ago. Is that a problem of pwnbox?

Was having the same problem, couldn’t connect to the MySQL server. No matter what I tried!

(I’m connecting from my local PwnBox, haven’t tried below on the virtual/Parrot PwnBox.)

Then I’ve stumbled across another post that suggested to nmap the port:
nmap -Pn -vvvvv --reason -p or map -Pn -p

If the port show as ‘Closed’ , wait a minute and try again. If the port shows as ‘Open’
you can connect to the MySQL server with the provided commands:
mysql -u root -p -h -P -p

not sure if needed, but I’ve started MySQL too.
sudo service mysql start

Hope this helps!!

Yes, I’ve tried and somehow after first scanning, port was open and I was able to connect. But not anymore, after rescanning ports are closed, after changing target is the same. I wanted to take this module, but it’s really wasting time trying to connect

I guess the instructions are no so clear, you need to use “password” for the password

Hey guys I solved.
Just to click in “Click here to spawn the target system” and try to connect this target

and do the exercise.
Everything Works for me.

REMEMBER: Use the Machine of PwnBox :wink:

I am also having problems. In my case I connect, but when trying to run the SHOW DATABASES command nothing happens

You have to put “;” at the end of “SHOW DATABASES” so it will be like “show databases;”