This problem is not due to the type of database. Switching to another one won't prevent the problem.
This problem is caused by data that can be entered by a user on your site and inserted into the database. If the data is not checked and validated before it is entered into the database, a hacker can insert his own data or run his own SQL commands (even ones which replace or alter a record containing a password with the hacker's own password) ...
See this link for more information about SQL Injection -
http://www.php.net/manual/en/securit...-injection.php