To check if a given username and password match those stored in a MySQL database, you can use a SQL SELECT statement with a WHERE clause.