Common MySQL Error Messages in PHP Scripts or Programs

Has your PHP script or application, such as WordPress, been stopped with a MySQL error message? We have put together an overview of the most common causes and solutions for you.

Error message (similar) What does it mean? What can I do?    
"Warning: mysql_connect(): Access denied for user 'dbo123456789..." The MySQL server denies access to the database. Check the user name and password in the script.  
"Can't connect to database..." or also "Warning: mysql_fetch_array() expects parameter 1..." Is the database name correctly stored in the script?  
"Unknown MySQL server... no connection possible" No connection could be established because the specified MySQL server is unknown. Check the host name specified in the script (MySQL server). In most cases,"localhost" is still stored there.
Too many connections The number of simultaneous connections for this database has been reached. it is possible that you have briefly reached the connection limit due to an unusually high number of users. We recommend that you wait a while and then check whether the error continues to occur. If this error occurs frequently, check the service request. We would be happy to advise you on the choice of a more efficient package. Professional tip: Do not use a CHAR or VARCHAR data type. Use TINYINT or SMALLINT as INT data types. This will reduce memory requirements and increase performance. The connection may be delayed due to ongoing maintenance.  

Database Errors

Here are some common error messages you may encounter while working directly on your database:

Error Message Meaning Solution
#1046 - No database selected A database has not been selected This error appears if no database has been selected for import. The most common reason is that an import is being performed in PHPMyAdmin, but no target database for the import is specified. You simply have to click the target database.
#1062 (23000) at line 45: Duplicate entry '1' for key 'PRIMARY' A duplicate entry, '1', for the 'PRIMARY' key has been detected. When importing databases, you can specify within the import file how MySQL Server should handle duplicate entries. You can enter this directly in the database or specify it when exporting via phpmyadmin.
mysqldump Error: 'You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT DISTINCT LOGFILE_GROUP_NAME FROM INFORMATION_SCHEMA.FILE' when trying to dump tablespaces" You have an error in SQL syntax. This error can occur if you export a MySQL 4 database through SSH using MySQL syntax. If you save 'tablespaces', check the correct syntax for 'SELECT DISTINCT LOGFILE_GROUP_NAME FROM INFORMATION_SCHEMA.FILE' in the manual for the server version. When exporting through SSH, use the command "--no-tablespaces", for example: mysqldump --no-tablespaces --host=dbXX.ionos.co.uk --password=XYZ --user=dbo123456789 db123456789 > dump.sql.