spencerlambert / mysql-events

A node meteor package that watches a MySQL database and runs callbacks on matched events.
Other
87 stars 76 forks source link

Nothing's happening... #13

Closed bennetgallein closed 8 years ago

bennetgallein commented 8 years ago

I'm using zwamp for coding on the move and it has normal mysql. I don't get any error in the console..

my code

var dsn = {
    host: 'localhost',
    user: 'root',
    password: '',
};
var mysqlEventWatcher = mysqlevents(dsn);
var watcher = mysqlEventWatcher.add(
  'skinpay.payments',
  function (oldRow, newRow) {
      //row inserted
    console.log("New row inserted!");
    if (oldRow === null) {
      //insert code goes here 
    }

     //row deleted 
    if (newRow === null) {
      //delete code goes here 
    }

     //row updated 
    if (oldRow !== null && newRow !== null) {
      //update code goes here 
    }
  }, 
  'match this string or regex'
);

It should print something in the console if I insert something manually, right?

Looking for quick help.

spencerlambert commented 8 years ago

Do you have mysql biniary logging turned on and does the mysql user have replication privileges? I would recommend using a different user besides root.

https://dev.mysql.com/doc/refman/5.7/en/replication-howto-repuser.html

bennetgallein commented 8 years ago

I'm gonna try that tomorrow... Thanks for the fast response. :)

bennetgallein commented 8 years ago

Okay, so I added a new user following the instructions you send in your post.. But nothing's happening.. It should probably work with my root account, because it has all permissions, right? Here's my MySQL config and a Screenshot of the Users permissions.

my.txt https://gyazo.com/ea0ae782c880ee056de7fad851a0f817

spencerlambert commented 8 years ago

Is MySQL Binary Logging turned on?

spencerlambert commented 8 years ago

Also, remove the last argument from your code, or updated it to something you want to match on.

'match this string or regex'

bennetgallein commented 8 years ago

What should go in there? I want to listen if any new row gets inserted.. I don't want it to have any special value..

spencerlambert commented 8 years ago

Then just remove the argument completely.

bennetgallein commented 8 years ago

Okay, so I removed it now.. But still after inserting something manually nothing appears in the console..

spencerlambert commented 8 years ago

Then it's likely binary logs aren't turned on.

bennetgallein commented 8 years ago

But I dont get the error that it's not turned on.. But I should if it isn't right?

spencerlambert commented 8 years ago

If you don't know that binary logging is turned on, then you need to confirm that it is. I'm not sure how to configure binary logging with ZWAMP.

bennetgallein commented 8 years ago

Okay.. I didn't changed anything but magicly seems to work.. Thanks for the great support anyways.. :)