Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts

Wednesday, June 24, 2015

SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1

Hello,

Got this error message

SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1

We tried everything to insert in one table but this error didn't budged even for the simplest query we  wrote.

Then I found that there was a "TRIGGER" applied on this table which on insertion updates another table.

So the problem was with the stored procedure. There was some additional field in it.

I discovered the root cause as soon as I deleted the Trigger.

So the issue was with the error message, this error was not pin pointing that the field was missing on which table, due to the language of the error it seems like the error is with the immediate table but actually it can be with a connected one.

Hope this will help someone.

Thanx
Anshumaan Bakshi


Monday, April 27, 2015

Connection Failed: 'host' is not allowed to connect to this mysql server

Hello,

If you are getting following error while trying to connect your (PHP) application to a MySQL database

Connection Failed: 'host' is not allowed to connect to this MySQL server

Then this may due to limited privileges given to the user through which one s trying to connect with the server. Although a correct username and password is been used to connect still we have this error.

What happens is when a new MySQL user is added to a DB then the hostname name like localhost is added by default to user like user1@localhost. Now this user can access the DB for sure but while he is on the same machine not remotely.

The solution for this issue is to create a new user which has Any Host privileges "%" like

mysql> CREATE USER 'user2'@'%' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'user2'@'%' -> WITH GRANT OPTION;


Thanx
Anshumaan Bakshi

Monday, December 23, 2013

ERROR 2006 (HY000) at line 8245: MySQL server has gone away

Hello,

If you are trying to import an SQL file through command line on windows and you get this error message

ERROR 2006 (HY000) at line 8245: MySQL server has gone away

then you need to open your my.cnf or my.ini and update as

max_allowed_packet = 3000M

more than the size of the file you are trying to import, like I was trying to import a 2.2 GB file.

Thanx
Anshumaan Bakshi

Tuesday, October 22, 2013

Import MySql DB through command prompt on WAMP

Hello,

If we have a very large file to import on WAMP and PHPMyAdmin is dying due to various reasons then you can import the big file using CLI or through Dos

Follow the following steps.
  1. Run cmd command
  2. Assuming you have installed wamp on C: drive.
  3. C:>cd wamp
  4. C:\wamp>cd bin
  5. C:\wamp\bin>cd mysql
  6. C:\wamp\bin\mysql>cd mysql15.5.8
  7. C:\wamp\bin\mysql\mysql15.5.8>cd bin
  8. C:\wamp\bin\mysql\mysql15.5.8\bin>mysql.exe -u root -p dbname < sqlDump.sql
  9. Now we need to have the sqlDump.sql file inside C:\wamp\bin\mysql\mysql15.5.8\bin\ for direct execution of this command.
  10. If everything is fine, then this command will ask for the mysql password for username root and it should start importing the file on the mysql database.

Now what we are doing here is we are moving to WAMP's bin directory to locate the mysql.exe file. This command file is similar to the one we have on Linux and it behave s the same way, so we provide the information like username db and import sql file and it can easily be imported in our db.

Please note: We can also use direct path from any location as soon as we come to cmd like C:\wamp\bin\mysql\mysql15.5.8\bin\mysql.exe -u root dbname < sqlDump.sql
but need to be sure of the path which is hard to locate.

Thanx
Anshumaan Bakshi