SQL database export-import

backup only all tables you need from localhost so your .sql file contain only the tables you need & after this go to your live server keep your databse as it the use the following cmd from unix/linux SSH to keep the old tables & only restore the new tables mysql -u username -ppassword databasename … Read more

How to interact with another wordpress install on same database?

Reading through the source code for the wpdb class, I see no reason why something like this shouldn’t work: $otherdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); $otherdb->prefix = ‘wp2_’; And then (if I’m understanding this right) you can use all the existing $wpdb methods and variables. Eg: $x = $otherdb->get_results( $sql_query ); (If I’m wrong … Read more

Why doesn’t this code add a table to my database?

A key must be defined for a table by using a single column, or multiple. So on your code, you need to a line to the sql KEY id (id) – $sql = “CREATE TABLE $table_name ( id int NOT NULL AUTO_INCREMENT, feedurl text NOT NULL, category text NOT NULL, KEY id (id) );”;

WordPress database error – Error in SQL syntax – I can’t identify any error?

You want the query to look like this: SELECT email FROM wp_my_users WHERE email=”[email protected]” instead of this: SELECT email FROM ‘wp_my_users’ WHERE email=”[email protected]” So try to construct your query with: $sql = “SELECT email FROM {$my_table_name} WHERE email = %s”; $result = $wpdb->get_var( $wpdb->prepare( $sql, $email_address ) ); where you don’t need to escape the … Read more

Changing Table Prefix for an Existing WordPresss Site

This is pretty straightforward. You can use phpMyAdmin or MySQL Workbench to change the prefix on all the tables at once, or you can do it one-at-a-time with a tool like SequelPro. If you need to run the SQL by hand, the syntax is… RENAME TABLE `old_name` TO `new_name`; Once all the table names are … Read more