Showing entries 1 to 7
Displaying posts with tag: MySQL Error Code (reset)
[Solved] MySQL User Operation - ERROR 1396 (HY000): Operation CREATE / DROP USER failed for 'user'@'host'

Error Message: ERROR 1396 (HY000): Operation CREATE USER failed for 'admin'@'%'
Generic Error Message:Operation %s failed for %s
Error Scenario:Operation CREATE USER failed
Operation DROP USER failed

Reason:The reason for this error is, you are trying to do some user operation but the user does not exist on the MySQL system. Also, for drop user, the user details are stored somewhere in the system, even though, you have already dropped the user from MySQL server.
Resolution:Revoke all access granted to the user, drop the user, and run FLUSH PRIVILEGE command to remove the caches. Now create/drop/alter the user, it will work.
REVOKE ALL ON *.* FROM 'user'@'host';DROP USER 'user'@'host';FLUSH PRIVILEGES;
Grant Tables:The following tables will help you in identifying the user related informations (as of MySQL 5.7):

mysql.user: User accounts, global privileges, and other non-privilege …

[Read more]
[Solved] Can’t connect to MySQL Server

There are a lot of different reasons behind this error. Sometime, you may not see the exact issue on the error message. You have to dig deeper to identify the exact cause. It may take a lot of time and energy to debug this error. I have encountered this error many times, so based on my experience and research on this issue; I have gathered and given the following possible reasons and workarounds to fix this error.

Error Message:

Can't connect to local MySQL server

Reason 1:

MySQL Server is not running on the server.

Workaround 1:

Check MySQL server is running on the server.

MySQL process name                    : mysqld

MySQL default …

[Read more]
[Solved] ERROR 1040: Too many connections - How to fix MySQL Too many connections error?

Error Message:
ERROR 1040 (HY000): Too many connections

MySQL Too many connections

Reason for this error:
This error occurs when connection reaches the maximum limit as defined in the configuration file. The variables holding this value is max_connections
To check the current value of this variable, login as root user and run the following command:
show global variables like max_connections;

[Read more]
[Solved] ERROR 1045 (28000): Access denied for user 'user'@'host' (using password: YES)

Error messageError 1045 (28000): Access denied for user ‘user’@’host’ (using password: YES)Debugging Summary

  • Check for typo error: username or password. 
  • Check the host name and compare it with mysql.user table host name. 
  • Check user exists or not. 
  • Check whether host contains IP address or host name.

There is a great chance that, you might have encountered this issue multiple times in your work. This issue occurred to me most of times due to the incorrectly entering user name or password. Though this is one of the reasons, there are other many chances you might get this issue. Sometimes, it looks very similar, but when you dig deeper, you will realize multiple factors contributing to this error. This post will explain in detail, most of the common reasons and work around to fix this issue. 

Possible reasons:

  • Case 1: …
[Read more]
[Solved] How to write a stored procedure in MySQL for insert?


When multiple client applications such as web applications, desktop applications and mobile applications written in different languages like php, python, java, objective c, etc. need to perform the same database operation (insert), the same operations done by different client applications and client applications are directly accessing the database table using same SQL statement.

Solutions:We are implementing stored procedure; here the client applications will simply call the defined stored procedures to perform the database operation (insert). In this post let us see about the syntax of the stored procedure and will see an example of insert operation using stored procedure using MySQL.


mysql> DELIMITER //
mysql> CREATE PROCEDURE Procedure_name(arguments) 
     ->  BEGIN 
     -> SQL Statements; …
[Read more]
[Solved] How to solve MySQL error code: 1215 cannot add foreign key constraint?

Error Message:
Error Code: 1215. Cannot add foreign key constraint
Error Code: 1215. Cannot add foreign key constraint
  Possible Reason: Case 1: MySQL storage engine. MySQL supports several storage engines, comparing features of the different mysql storage engines are given below. Note that only InnoDB storage engine supports foreign key, when you are using different mysql storage engine you may get the error code: 1215 cannot add foreign key constraint.


Case 2: Key does not exist in the parent table. When …

[Read more]
[Solved] How to solve MySQL error code: 1062 duplicate entry?

Error Message:

Error Code: 1062. Duplicate entry ‘%s’ for key %d

Error Code: 1062. Duplicate entry ‘1’ for key ‘PRIMARY’

Possible Reason:
Case 1: Duplicate value.
The data you are trying to insert is already present in the column primary key. The primary key column is unique and it will not accept the duplicate entry.

Case 2: Unique data field.
You are trying to add a column to an existing table which contains data and set it as unique.

Case 3: Data type –upper limit.
The auto_increment field reached its maximum range.

[Read more]
Showing entries 1 to 7