Short answer: SQL injection happens when a website puts visitor input straight into a database query. Attackers can then read, change or delete data. Protection comes from code that uses parameterised queries, plus updates, a web application firewall and minimal database privileges.
How it works, simply
A search box or URL parameter is meant to hold ordinary text. If the site pastes that text directly into a database command, an attacker can type database instructions instead of a search term.
What attackers can do
- Read customer data, such as emails or orders.
- Create admin accounts.
- Change or delete content.
Protections
- Parameterised queries in your site's code (developers' job).
- Keep software updated: most real attacks exploit known plugin bugs. See updating WordPress safely.
- A web application firewall blocks common patterns. See WAF.
- Least privilege: the website's database user shouldn't have more rights than it needs.
- Backups so you can recover. See the 3-2-1 rule.
Questions to ask a developer
- Do you use prepared statements everywhere?
- How is user input validated?
- How quickly do you apply security updates?
Frequently asked questions
Is WordPress vulnerable to SQL injection?
WordPress core uses safe query methods. Vulnerabilities usually come from outdated or poorly written plugins.
How would I know if it happened?
Unknown admin users, changed content or alerts from your security tools. See scanning for malware.



