Warning
Error Code:
1287
MariaDB Error 1287: Deprecated Syntax Usage Detected
Description
MariaDB Error 1287 indicates that your query or command is using a deprecated syntax, function, or feature. While it currently functions as a warning, this construct is slated for removal in future MariaDB releases, potentially causing errors after an upgrade. It highlights the use of an outdated element that has a recommended modern alternative.
Error Message
'%s' is deprecated and will be removed in a future release. Please use %s instead
Known Causes
3 known causesOutdated SQL Syntax
A SQL query or statement uses syntax that has been superseded by a newer, more efficient, or more standard alternative in recent MariaDB versions.
Deprecated Functions or Variables
The code explicitly calls a function, uses a system variable, or accesses a feature that MariaDB has marked as deprecated and plans to remove.
Migration from Older Versions
Existing applications or scripts developed for older MariaDB or MySQL versions may contain constructs that are now deprecated in the newer MariaDB release you are using.
Solutions
3 solutions available1. Update SQL Statements to Modern Syntax medium
Modify your SQL queries to use the recommended syntax instead of the deprecated one.
1
Identify the specific deprecated syntax causing the error. The error message '%s' is deprecated and will be removed in a future release. Please use %s instead' will tell you exactly what is deprecated and what to use. For example, if you see 'SELECT ... FOR UPDATE NOWAIT' is deprecated, use 'SELECT ... FOR UPDATE SKIP LOCKED' instead.
Example: Instead of `SELECT * FROM my_table FOR UPDATE NOWAIT;`
Use: `SELECT * FROM my_table FOR UPDATE SKIP LOCKED;`
2
Review your application's codebase, stored procedures, views, and any other SQL constructs for instances of the identified deprecated syntax.
3
Replace the deprecated syntax with the recommended alternative. Test thoroughly after making these changes to ensure functionality remains correct and no new issues arise.
2. Temporarily Disable Deprecation Warnings easy
Suppress the deprecation warnings if immediate code changes are not feasible.
1
Connect to your MariaDB server as a user with sufficient privileges (e.g., root).
2
Execute the following SQL command to set the `warning_level` system variable to 0. This will suppress all warnings, including deprecation warnings.
SET GLOBAL warning_level = 0;
3
Note: This is a temporary solution. It's highly recommended to address the deprecated syntax in your SQL code as soon as possible to avoid potential issues in future MariaDB versions.
3. Configure Deprecation Warning Thresholds medium
Adjust the `warning_level` system variable to control the verbosity of deprecation warnings.
1
Connect to your MariaDB server.
2
Check the current `warning_level` by running:
SHOW VARIABLES LIKE 'warning_level';
3
The `warning_level` variable controls the type of warnings displayed. A value of 4 (the default) includes deprecation warnings. You can set it to a lower value to filter out certain types of warnings. For example, setting it to 3 would exclude deprecation warnings.
SET GLOBAL warning_level = 3; -- Excludes deprecation warnings
4
To make this change persistent across server restarts, add `warning_level = 3` (or your desired value) to your `my.cnf` or `my.ini` configuration file under the `[mysqld]` section.
[mysqld]
warning_level = 3
5
Restart the MariaDB server after modifying the configuration file.