0

i have a hosting and wordpress design and want to know how to make 2 websites use
just one database ? can anyone help me, do i have to change the wp_options ?

$table_prefix = ‘wp_’;
define(‘CUSTOM_USER_TABLE’, $table_prefix.’global_users’);
define(‘CUSTOM_USER_META_TABLE’, $table_prefix.’global_usermeta’);

define(‘WP_ALLOW_MULTISITE’, true);
O E
  • 17
  • 6

1 Answers1

0

You can use the same "wp-config" when you want to "mirror" the page. If you simply want to host two WordPress websites from the same database you need to change the $table_prefix in the "wp-config".

Siggy
  • 324
  • 2
  • 11
  • Aha it means it can be done . i want 2 websites using one database but the other website is @ another provirder ? – O E Dec 07 '17 at 22:33
  • If the database is reachable from the internet it is possible but the default should be, that the database only listens on "localhost" (127.0.0.1). If the later is the case it isn't possible until you change the database configuration to listen to (any-interface) "0.0.0.0". – Siggy Dec 07 '17 at 22:40
  • Aha i have to make the other website listen to "localhost' (127.0.0.1) to use onedatabase/ The website is about to have one stock / example when someone ordered a book from the #1 website the quantity must be -1 to #2nd website ? Just the stock i need only the stock.. – O E Dec 07 '17 at 22:44
  • Lets say website 1 is hosted by X and website 2 is hosted by Y and you want to have website 2 using the same database as website 2, you need to check if the X (the provider of website 1) has configured the database to listen on (127.0.0.1). If that is the case you need to change the configuration of the database to listen on (0.0.0.0). After changing the configuration you need to reload / restart the database and change the "wp-config" of website 2 to use the public IP of the database server in the "DB_HOST" option. – Siggy Dec 07 '17 at 23:02
  • Aha really nice' can you tell me what code i have to use to make the database listen on (127.0.0.1) ? – O E Dec 07 '17 at 23:08
  • This depends on the database you're using. I would guess that you're using MySQL so you could follow these steps: https://stackoverflow.com/a/14779244/7692940 – Siggy Dec 07 '17 at 23:16