MYSQL - Querying multiple wordpress databases at once ? - mysql

I need to execute an cleaning operation on my mysql databases,
I have 140 wordpress databases under the same connection.
I have ~30 forbidden words.
I need to query all wp-post tables post-content columns find these 30 words,
and remove the rows that include one of these words.
I must do it on each databases at once!

You could write a small program in java or c# to actually loop through all the databases.
If you execute
show databases; this will retrieve all the databases that are present on you connection. From there I assume you know the tables on which you want to query for your forbidden words. Then you can loop within this new application for each database present and you will be able to query the wanted table.
Let me know if this is what you were expecting. If you want some code sample let me know.

Related

Export only the indexes from mysql database

I have a mysql database. For which I need to retrieve only the indexes present in my entire database, Is there any way I could get it? OR get a
CREATE indexes script which will help me do so.
I just don't want to SELECT them, rather I would like to get a script which when executed on similar database - the indexes will be added

Access Delete Query Deleting Tables on Multiple Databases

I am using access 2007. In the database I am using a delete query to remove data from a table. What shocks me is that even though I have create multiple duplicates of the database in several different locations and with different names on the same server PC, the minute I run the delete query it removes all other tables on the other databases which I do not wish for as they are backups.
Could someone please help to explain why my delete query is not limiting itself to one database.
Thanks
Found my answer. The database was broken up into a back and front end. Making duplicates of the front end still was linked to the original back end. Had to copy over tables from back end to front end to make the database a single entity again.

Mysql views return data when table empty

I am having a weird problem with mysql. I am developing a visual application on C# that stores data into a database. Previously I used SQL for the Database, but my client changed his mind for mysql. So I recreated the same schema on mysql. Now it is happening a really odd thing: My tables are completely empty, but when I execute the views, they return me back data from the old SQL tables, when I read directly from the tables they appear empty. The user that I use to connect are different and the most strange thing is that it happens even when I execute the view on mysql workbench. I have even truncated the tables in mysql and still the same thing. Does anybody know what may cause this anomaly and how to solve it?
p.s. Workbench version 6.2; Sql version SQL SERVER 2014
Regards.
In MySQL, a view is a virtual table based on the result-set of an SQL statement.
It contains rows and columns, just like a real table in your database. The fields in a view are fields from one or more real tables in the database.
When you execute the views, they return back data from the old SQL tables. It is because your view still contains the data you run a while ago. You have forgotten to Drop your View every time you execute it. To Drop a MySQL view, try this one:
DROP VIEW view_name
Views do NOT contain data of any kind -- except for Materialized Views and MySQL does not have those. If views had to be dropped and recreated every time a DML statement was executed on a table, views would be utterly useless.
The only time a view can return old data is when one process changes the contents of a table used in the view and the view is queried by another process before the first process commits the changes. You have not specified how the tables are being changed and how they are being queried. Nor have you included the create view statement. You could well be using other tables than what you think. This can happen during initial design of a database if tables are being slapped around like mad.

What is the size limit for a Query/View table in MySQL?

I am using MySQL and currently have 3 tables in a database. I created a view table with relationships between the 3 tables. The view table should be about 200 000 rows of data because i also tested the same query in Access and it works fine, but unfortunately i am not allowed to use Access.
When i build the view in MySQL i get a message that says the view was build successfully. But when i try to actually view the data, it gives me something like, MySQL ran out of memory. I am not sure what i can do differently to avoid this message. Can someone please give some advice?
You can use the Quick option for running your query.
Do not cache each query result, print each row as it is received. This
may slow down the server if the output is suspended. With this option,
mysql does not use the history file.

Querying MySQL and MSSQL databases at the same time

I'm getting data from an MSSQL DB ("A") and inserting into a MySQL DB ("B") using the date created in the MSSQL DB. I'm doing it with simple logics, but there's got to be a faster and more efficient way of doing this. Below is the sequence of logics involved:
Create one connection for MSSQL DB and one connection for MySQL DB.
Grab all of data from A that meet the date range criterion provided.
Check to see which of the data obtained are not present in B.
Insert these new data into B.
As you can imagine, step 2 is basically a loop, which can easily max out the time limit on the server, and I feel like there must be a way of doing this must faster and during when the first query is made. Can anyone point me to right direction to achieve this? Can you make "one" connection to both of the DBs and do something like below?
SELECT * FROM A.some_table_in_A.some_column WHERE
"it doesn't exist in" B.some_table_in_B.some_column
A linked server might suit this
A linked server allows for access to distributed, heterogeneous
queries against OLE DB data sources. After a linked server is created,
distributed queries can be run against this server, and queries can
join tables from more than one data source. If the linked server is
defined as an instance of SQL Server, remote stored procedures can be
executed.
Check out this HOWTO as well
If I understand your question right, you're just trying to move things in the MSSQL DB into the MySQL DB. I'm also assuming there is some sort of filter criteria you're using to do the migration. If this is correct, you might try using a stored procedure in MSSQL that can do the querying of the MySQL database with a distributed query. You can then use that stored procedure to do the loops or checks on the database side and the front end server will only need to make one connection.
If the MySQL database has a primary key defined, you can at least skip step 3 ("Check to see which of the data obtained are not present in B"). Use INSERT IGNORE INTO... and it will attempt to insert all the records, silently skipping over ones where a record with the primary key already exists.