mysql

mysqldump with federated tables

I need mysqldump including the data, but in database there are also couple of tables with FEDERATED engine. The mysqldump includes INSERTs for FEDERATED tables too, what makes for exemaple "Duplicate entry" errors (because the table is already filled with data). I can dump structure and data separately and then remove INSERTs for FEDERA...

mysql "with" clause

I'm trying to use mysql to create a view with the "with" clause with authorRating(aname, rating) as select aname, avg(quantity) from book group by aname but it doesn't seem like mysql supports this. I thought this was pretty standard and I'm sure Oracle supports this. Is there anyway to force mysql to use the "with" clause?...

Integrated authentication for mysql

When working with MSSQL on Windows I was used to a very convenient feature called integrated authentication. In short, being authenticated in Windows can give you access to the database, so no need to give any specific password. Now I am developing an application on Linux with no user interaction; this application needs to access a mysql...

Which is the best way to bi-directionally synchronize dynamic data in real time using mysql

Here is the scenario. 2 web servers in two separate locations having two mysql databases with identical tables. The data within the tables is also expected to be identical in real time. Here is the problem. if a user in either location simultaneously enters a new record into identical tables, as illustrated in the two first tables belo...

Best language choice for a spam detection service

I have around 20 or so active blogs that get quite a bit of spam. As I hate CAPCHA the alternative is very smart spam filtering. I want to build a simple REST api like spam checking service which I would use in all my blogs. That way I can consolidate IP blocks and offload spam detection to 3rd party such as Akisment, Mollom, Defensio ...

Can I atomically rename/replace 2 or more tables and views?

Given a table X and a view Y (that has the same structure as X) is there a way to rename X to Z and Y to X atomically so that no query will ever see nothing named X? Renaming X and creating the view would also be valid. The point would be to, as part of a schema migration plan, replace the old tables with views that simulate the old ver...

How to implement background/asynchronous write-behind caching in PHP?

I have a particular PHP page that, for various reasons, needs to save ~200 fields to a database. These are 200 separate insert and/or update statements. Now the obvious thing to do is reduce this number but, like I said, for reasons I won't bother going into I can't do this. I wasn't expecting this problem. Selects seem reasonably pe...

MySQL Prepared statements with a variable size variable list

How would you write a prepared MySQL statement in PHP that takes a differing number of arguments each time. An example such query is: SELECT age, name FROM people WHERE id IN (12, 45, 65, 33) The IN CLAUSE will have a different number of id's each time it is run. I have two possible solutions in my mind but want to see if there is a b...

MySQL stored procedure vs. multiple selects

Hi all, Here's my scenario: I've got a table of (let's call them) nodes. Primary key on each one is simply "node_id". I've got a table maintaining a hierarchy of nodes, with only two columns: parent_node_id and child_node_id. The hierarchy is maintained in a separate table because nodes can have an N:N relationship. That is to say,...

Can we have the table name as "option" in MySQL?

I am very, very new to MYSQL.I tried to create a table named "option". My SQL Query is : create table option( id int not null primary key auto_increment, choice varchar(30) ) While executing this query it shows the following error Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MyS...

Wildcards in Java PreparedStatements

Here's my current SQL statement: SEARCH_ALBUMS_SQL = "SELECT * FROM albums WHERE title LIKE ? OR artist LIKE ?;"; It's returning exact matches to the album or artist names, but not anything else. I can't use a '%' in the statement or I get errors. How do I add wildcards to a prepared statement? (I'm using Java5 and MySQL) Thanks! ...

Is it unreasonable to assign a MySQL database to each user on my site?

I'm creating a user-based website. For each user, I'll need a few MySQL tables to store different types of information (that is, userInfo, quotesSubmitted, and ratesSubmitted). Is it a better idea to: a) Create one database for the site (that is, "mySite") and then hundreds or thousands of tables inside this (that is, "userInfo_bob", "...

Ubuntu myphpadmin and mysql dpkg problem

I'm attempting to install myphpadmin, but I constantly get errors. When i type this in the terminal: sudo dpkg --configure -a The following message appear: Setting up mysql-server-5.0 (5.0.45-1ubuntu3) ... * Stopping MySQL database server mysqld [OK] * Starting MySQL database server mysqld [...

Synchronizing databases

Hi I am developing an Adobe AIR application which stores data locally using a SQLite database. At any time, I want the end user to synchronize his/her local data to a central MySQL database. Any tips, advice for getting this right? Performance and stability is the key (besides security ;)) ...

Why does my INSERT sometimes fail with "no such field"?

I've been using the following snippet in developements for years. Now all of a sudden I get a DB Error: no such field warning $process = "process"; $create = $connection->query ( "INSERT INTO summery (process) VALUES($process)" ); if (DB::isError($create)) die($create->getMessage($create)); but it's fine if I use numerics $process =...

Transfer Mysql database to another computer

Hey, I have a mysql database filled up and running on a windows computer, is there any tool to transfer the database to another computer (running ubuntu)? Else I'll just write a script to take all the data base into SQL and insert it on the other computer. Just trying to save some time :) Thank you all. ...

How can I implement commit/rollback for MySQL in PHP?

Well basically I have this script that takes a long time to execute and occasionally times out and leaves semi-complete data floating around my database. (Yes I know in a perfect world I would fix THAT instead of implementing commits and rollbacks but I am forced to not do that) Here is my basic code (dumbed down for simplicity): $data...

How to use connection pool with java,MySQL and Tomcat 6

How can I use Connection pool in Java+MySQL+Tomcat 6? I've read this article http://dev.mysql.com/tech-resources/articles/connection_pooling_with_connectorj.html but it is still not quite clear for me. Where do I use the Connector/J? Do I put it in a static variable? Do I use a SessionListener? Does it need any configuration? Thank ...

MySQL strict select of rows involving many to many tables

I have three tables in the many-to-many format. I.e, table A, B, and AB set up as you'd expect. Given some set of A ids, I need to select only the rows in AB that match all of the ids. Something like the following won't work: "SELECT * FROM AB WHERE A_id = 1 AND A_id = 2 AND A_id = 3 AND ... " As no single row will have more than on...

connecting to mysql from cygwin

I can successfully connect to MySQL from a DOS prompt, but when I try to connect from cygwin, it just hangs. $/cygdrive/c/Program\ Files/MySQL/MySQL\ Server\ 5.1/bin/mysql -u root -p What's wrong? ...