i'm new in asking questions here in the site, here is the situation:
Im using a Xampp Control Panel,
I have two systems, the old one and the new one (the new one is just the upgraded version of the old one).
I have 2 databases, let's name it db1 and db2, (db1 is the dbase used for the old one, and db2 is the dbase used for the new one.)
both databases have the same tables and contents except for one table, in db1.tb_final_dtr the structure has only 10 columns while db2.tb_final_dtr has 11 columns though the 10 columns in each table is the same with each other, and also both tables have the same records.
-I tried to queried both database with simple query lets say "SELECT * FROM tb_final_dtr WHERE hr_id = 'ASM12-0101'", the problem is, db1 shown 10 records right away, while db2 shown empty result. They both have the same table structure and records, they just differ in database name and the number of columns in one table.
WHAT SEEMS TO BE THE PROBLEM? hope you can reply at my question right away. Thanks a lot.
Your DB_2 is not working on NEW system..
Go to PHPmyadmin (on your NEW system) and add new user with username & password written from your conf file (and server name as localhost) of your website :P
So
go to PMA
add new user
enter data (server, username, password)
reload mysql
Of course, DB name in config file may also be wrong if tables are duplicated who knows what so check that too.
Good luck!
Related
I'm working on joomla plugin that could help me with backups of my site.
I have problem with copying database of one site to another. Both databases have different users. I tried to use query like that:
INSERT INTO new_table SELECT * FROM another_database.old_table
Unfortunately I got an error:
SELECT command denied to user 'user_old'#'ip' for table 'old_table'
I understand an error, but I cant create another user that could have priviliges to both databases.
Can I somehow work this out in php? I create connection to both databases, but is there a way of doing this other than
SELECT * FROM old_table
then inserting all data fetched to new_table?
I would like to not use mysqldump because I want to have control which tables I will copy.
You can use mysqldump to get all the tables, load that sql file into the new database and then run:
DROP TABLE <table_name>;
on all the tables you do not want in the new database.
I have a database and it contains 4 tables. I am inputting some data there using PHP locally. Then I hired a coder to help me input, we are from different places so I uploaded my PHP scripts and my database in a shared hosting site.
I know that I can also use the site I uploaded for us to have the same database while coding.
Now my problem is I already have a thousand accounts and phpmyadmin loads so slow when I try to check something and edit. So therefor I am coding on my localhost.
Is there a way that I can merge the database of my coder and mine when we are both finished?
Merge the two with double data by exporting one into the other without DROP TABLE arguments, then you can delete columns with something like this.
DELETE FROM table WHERE id = (SELECT id, DISTINCT email FROM table)
this will delete all rows that have duplicate email fields.
Here is the setup, I have multiple online stores that I would like to use the same product database. Currently they are all separate, so updating anything requires going through and copying products over, it is a giant pain. What I would like to do is create a master product database that every night, each site will compare its database with, and make updates accordingly.
The idea is one master database of products that will be updated a few times a day, and then say at 2:00 AM, a cron job will run pulling the updates to the individual websites.
Just a few more details on the database, there is one table 'products' that needs to be compared, but it also needs to look at table 'prodcuts_site_status' to determine the value for the products status for each given site, so I can't simply dump the master table and re-important it into the site databases.
Creating a php script to go row by row and compare and update would be easy enough, but I was hoping there existed a more elegant/efficient solution in mysql. Any suggestions?
Thanks!
To sum up you could try 3 different methods:
use SELECT ... INTO OUTFILE and then LOAD DATA INFILE from MySQL Cross Server Select Query
use the replication approach described here Perl: How to copy/mirror remote MYSQL table(s) to another database? Possibly different structure too?
use a FEDERATED storage engine to join tables from different servers http://dev.mysql.com/doc/refman/5.0/en/federated-storage-engine.html
At our company we have a business solution which includes CMS, CRM and several other systems.
These are installed in several domains, for each of our clients.
The systems are still in development, so new tables and fields are added to the database.
Each time we want to release a new version to our clients, i have to go through their database and insert the new fields and tables manually.
Is there a way that this could be done automatically(a script maybe that detects the new fields and tables and inserts them?)
We are using php and mysql.
We would like to avoid backing up the clients data, dropping the database tables, running the sql query to insert all the database tables(including the new ones) and then re-inserting the customers data. Is this possible?
Toad for MySQL
DB Extract, Compare-and-Search Utility — Lets you compare two MySQL databases, view the differences, and create the script to update the target.
What you are looking for is
ALTER TABLE 'xyz' ADD 'new_colum' INT(10) DEFAULT '0' NOT NULL;
or if you want to get rid of a colum
ALTER TABLE 'xyz' DROP 'new_colum';
Put all table edits into an update.php file and the either call and delete it once manually or try to select "new_colum" once and update the database when it's not present.
OR what I do: "I have a settingsfield "software version" and use this as a trigger to update my tables.
But since you have to install the new scripts anyways you can just call it manually.
Is there already any software that will allow me to select a table or row from existing DB, edit that table, add new rows, or clone existing ones, then insert the new rows back into the DB?
Read: i want to ADD this data, do not want to update/replace existing data.
PHP5, and MySQL 5
There's PHPMyAdmin, which will let you to pretty much anything to a database.
You can clone rows by editing and selecting "insert as new row" (may have to blank out the primary key if you have one).
MySQL Administrator is a decent GUI put out by MySQL that should handle all of that. I'm quite happy with it.
There's also HeidiSQL which is a windows client for managing MySQL databases:
http://www.heidisql.com/
And there's jHeidi from the same site that's java based and so should run on other operating systems.