Full message: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'masterstroke.variable' doesn't exist.

This displays at the 2nd site install on Database Setup (browser > http://subdirsite1/install.php). masterstroke is DB 127.0.0.1:3306

My Config:

  • Windows Server 2012 r2 on local switched connection
  • Apache2.4 64bit running as service (C:\Apache24)
  • MySQL56 64bit running as service (w/ Workbench6.3 - Not phpMyAdmin)
  • PHP 64bit threadsafe
  • Drupal 7.38 (D:\htdocs\sites\subdirsite1)

I've read dozens of posts/comments on messages resembling this but are different and not applicable or the solution doesn't work. If I could get beyond this I'm pretty certain I would have this install licked so If anyone has an answer to above I would be very grateful.

I have the default Drupal site running with the localhost:3306 database. I created a second DB 127.0.0.1:3306 for the subdirsite1 install and both are connected and configurable in Workbench (C:\ProgramData\MySQL\MySQL Server 5.6\data\masterstroke). Is there something I need to have in the 2nd DB that I didn't need in the first one?

NOTE:

I seem to be having a problem with getting my replies posted and have requested a 'confirmed' user role so please be patient. Thanks!

Comments

vm’s picture

have you worked through: https://www.drupal.org/documentation/install/multi-site

It makes sense that the tables aren't found as they wouldn't yet been installed (assuming you've not yet run install.php).

Is the settings.php file for the subsite a virgin file from a copy of default.settings.php?

soundbyte’s picture

Thanks VMII. Please feel free to correct me on any of this...

https://www.drupal.org/documentation/install/multi-site

Yes, this was my initial spot when I couldn't get the second (subdirsite1) site to initiate install at all. I solved that by adding entries to the hostfile but the symlink stuff put me off as i thought that was referring to Linux installs. Am I wrong?

It makes sense that the tables aren't found as they wouldn't yet been installed (assuming you've not yet run install.php).

I thought of this so I copied tables from the first DB (localhost) and populated masterstroke DB. This didn't make any difference but I left them in there until I could think of something better.

Is the settings.php file for the subsite a virgin file from a copy of default.settings.php?

Seeing this was a problem for some, I copied the original default.settings.php into the root of subdirsite1, removing the default. as advised.

soundbyte’s picture

wusel’s picture

... and there look e.g. at Multi-site on XAMPP for Windows (https://www.drupal.org/node/1682040).
I know, that you don't use XAMPP, but the steps are the same!

Did you realy build two databases? Look at the web interface of your database server. Give them different names like in my link!

Hint: localhost and 127.0.0.1 are the same webserver and link to the same database-server.

Wusel

soundbyte’s picture

I put this reply in over 7hrs ago and it still hasn't been posted so I'm trying again.

Thanks VMII. Please feel free to correct me on any of this...

https://www.drupal.org/documentation/install/multi-site

Yes, this was my initial spot when I couldn't get the second (subdirsite1) site to initiate install at all. I solved that by adding entries to the hostfile but the symlink stuff put me off as i thought that was referring to Linux installs. Am I wrong?

It makes sense that the tables aren't found as they wouldn't yet been installed (assuming you've not yet run install.php).

I thought of this so I copied tables from the first DB (localhost) and populated masterstroke DB. This didn't make any difference but I left them in there until I could think of something better.

Is the settings.php file for the subsite a virgin file from a copy of default.settings.php?

Seeing this was a problem for some, I copied the original default.settings.php into the root of subdirsite1, removing the default. as advised.

wusel’s picture

Follow the steps in my link, only change your paths. Then you get it running!

Good luck!

Wusel

soundbyte’s picture

https://www.drupal.org/node/1682040

I had followed these steps previously which got me from a no show 404 on my second site to the install loading (over the moon at this point so THANKS!) See https://www.drupal.org/node/2313871#comment-10147168

But when I uncommented the httpd-vhosts.conf line in httpd.conf the install would fail and I would have to put in a fresh settings.php and start again.

# Virtual hosts
Include "conf/extra/httpd-vhosts.conf"

Could there be something wrong with my httpd-vhosts.conf?

# Virtual Hosts
#
# Required modules: mod_log_config
#(Everything before and after this point is commented)
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:8080>
    ServerAdmin info@mywork.com
    DocumentRoot "c:/Apache24/htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *:8080>
   ServerAdmin info@mywork.com
   DocumentRoot "D:\htdocs\sites"
   ServerName subdirsite1
   ErrorLog "D:\htdocs\sites\subdirsite1\logs\error_log
   CustomLog "D:\htdocs\sites\subdirsite1\logs\custom_log" common
<Directory "D:\htdocs\sites">
   Options Indexes FollowSymLinks
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>
</VirtualHost>
wusel’s picture

You need to add the second ServerName within your file httpd-vhosts.conf like

<VirtualHost *:8080>
   ServerAdmin info@mywork.com
   DocumentRoot "D:\htdocs\sites"
   ServerName subdirsite2
   ErrorLog "D:\htdocs\sites\subdirsite2\logs\error_log
   CustomLog "D:\htdocs\sites\subdirsite2\logs\custom_log" common
<Directory "D:\htdocs\sites">
   Options Indexes FollowSymLinks
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>
</VirtualHost>

It is one of my steps. Did you follow the other steps completely???

Hint:
Everywhere where I have listed both sites or both registrations all steps must be carried out completely, as well as previously listed under step 3 in my link.

Good luck!

Wusel

soundbyte’s picture

I went through each of your steps carefully, changing what was needed to get the sites to resolve correctly. I removed the 2nd sub-directory site (subdirsite2) to make troubleshooting easier as it didn't make any difference to solving the problem. I added it back just to be sure but there was no change.

New httpd-vhosts.conf

<VirtualHost *:8080>
    ServerAdmin info@mywork.com
    DocumentRoot "c:/Apache24/htdocs"
    ServerName localhost
    ServerAlias www.localhost:8080
    ErrorLog "D:\htdocs\sites\default\logs\error_log"
    CustomLog "D:\htdocs\sites\default\logs\custom_log" combined
</VirtualHost>

<VirtualHost *:8080>
   ServerAdmin info@mywork.com
   DocumentRoot "D:\htdocs\sites"
   ServerName subdirsite1
   ServerAlias www.subdirsite1:8080  
   ErrorLog "D:\htdocs\sites\subdirsite1\logs\error_log
   CustomLog "D:\htdocs\sites\subdirsite1\logs\custom_log" combined
</VirtualHost>

<VirtualHost *:8080>
   ServerAdmin info@mywork.com
   DocumentRoot "D:\htdocs\sites"
   ServerName subdirsite2
   ServerAlias www.subdirsite2:8080  
   ErrorLog "D:\htdocs\sites\subdirsite2\logs\error_log
   CustomLog "D:\htdocs\sites\subdirsite2\logs\custom_log" combined
</VirtualHost>

<Directory "D:\htdocs\sites">
   Options Indexes FollowSymLinks
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>
</VirtualHost>

and new hosts file

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost

127.0.0.1 subdirsite1
127.0.0.1 subdirsite2
127.0.0.1 www.subdirsite1
127.0.0.1 www.subdirsite2

As one would expect I can browse to the install script with each of the above 4 urls above (suffixed with :8080 of course) but what bothers me is the fact that Apache fails to start whenever I uncomment Include conf/extra/httpd-vhosts.conf in httpd.conf (your step #2). Secondly, it is the database setup the install always fails on. I have even tried to use the original localhost DB that I used with the default site (which works perfectly with the default site BTW). It seems to me this is an issue with the database and Drupal not communicating for the sub-directory sites only.

I thought about reinstalling MySQL but I'm not optimistic as the DBs seem to be running fine. Is there some element/script that interfaces directly between Drupal and MySQL, etc. I should be looking at?

wusel’s picture

I can not see, where I have said that e.g.
ServerAlias www.subdirsite2:8080
is correct.

I think, my code looks more like
ServerAlias www.subdirsite2
without any ":8080" in that line!

You have made this error more than once!

And you have more errors in your config file. But that is not drupal...


ToDo:
Please set up a new dev website on that server and follow my ToDo-List "step for step" without any changes.
If that runs, you can change ONE item. Only ONE item, check what happens, change ONE item, check... and so on...

Hint:
You should check your config files to be ok by asking your webserver. Look at the docs of your webserver Apache in the internet (e.g. at http://httpd.apache.org/docs/)...
For XAMPP on windows you will find:
C:\xampp\apache\bin\httpd.exe -t

Wusel

soundbyte’s picture

I went through each of your steps carefully, changing what was needed to get the sites to resolve correctly.

Apache is setup to listen on 8080. If I remove the port designation (:8080) the named urls (localhost, subdirsite1, subdirsite2 will not resolve and the install page will not load as I have experienced. I have IIS running on port 80 (for non-Drupal static sites) so port 8080 on Apache is necessary to avoid the port conflict, No? I could swap the ports around so IIS is on 8080 instead. Will give a try.

(I have to set up this dev sever exactly the way I will need to set up the production server to avoid live issues which would be catastrophic for our commerce sites.)

soundbyte’s picture

OK, using your config, I setup dummy-host.localhost and dummy-host2.localhost sites, both DBs were created as dummyhost & dummyhost2 with connection tested, updating the other files (host, and httpd-vhosts.conf as follows:

127.0.0.1    dummy-host.localhost
127.0.0.1    dummy-host2.localhost
127.0.0.1    www.dummy-host.localhost
127.0.0.1    www.dummy-host2.localhost
<VirtualHost *:80>
ServerAdmin postmaster@host.localhost
DocumentRoot "D:/htdocs/sites/drupal"
ServerName localhost
ServerAlias www.localhost
ErrorLog "logs/host.localhost-error.log"
CustomLog "logs/host.localhost-access.log" combined
</VirtualHost>

<VirtualHost *:80>
ServerAdmin postmaster@dummy-host.localhost
DocumentRoot "D:/htdocs/drupal"
ServerName dummy-host.localhost
ServerAlias www.dummy-host.localhost
ErrorLog "logs/dummy-host.localhost-error.log"
CustomLog "logs/dummy-host.localhost-access.log" combined
</VirtualHost>

<VirtualHost *:80>
ServerAdmin postmaster@dummy-host2.localhost
DocumentRoot "D:/htdocs/drupal"
ServerName dummy-host2.localhost
ServerAlias www.dummy-host2.localhost
ErrorLog "logs/dummy-host2.localhost-error.log"
CustomLog "logs/dummy-host2.localhost-access.log" combined
</VirtualHost>

Both urls wouldn't resolve until I put the following into the httpd.conf file:

URL: http://localhost/dummy-host.localhost
 $sites['localhost.dummy-host.localhost'] = 'dummy-host.localhost';

But that only created a different issue with the same 'localhost default site' loading at www.dummy-host.localhost and http://www.dummy-host2.localhost. Do I now try to resolve this issue or go back to the previous setup?

UDATE:

After deleting MY added lines above to httpd.conf, and dumping mem cache, I copied the default.settings.php file to the each dummysite and renaming to settings.php, the install script loaded for both sites but, again, failed on 'setup database' bit with a similar message to the top of this post:

Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [1049] Unknown database 'dummyhost2'.
wusel’s picture

ToDo:
Please set up a new dev website on that server and follow my ToDo-List "step for step" without any changes.
If that runs, you can change ONE item. Only ONE item, check what happens, change ONE item, check... and so on...

You did not follow!

Are you missing the file .htaccess or the needed Apache 'mod_rewrite' extension or the running of the file .htaccess?

=> Don't change a "running team", until you know, why you have to do this!

Did you ever read the Installation Guide (https://drupal.org/documentation/install) and its linked pages complete and careful, before you start your post at the top of this page?

You delete the settings of that website, if you delete any of the files settings.php! Why do you delete such a file?
Are you knowing, how to setup and install a normal website with Drupal 7? I can not believe this...

My very last hint:
So learn first how Drupal works on a single website installation on your server and then go on with the topic of your first post on this page!

Wusel

soundbyte’s picture

As suspected the title error message DID have to do with a database flaw (most likely mine) and not so much with the php scripts.

I created all the site databases in Workbench, tested the connections, etc. so I thought all was well until today when I decided to cross check them with mysql monitor CL. On a 'show databases' I found only one of the databases I created was actually listed (the very first test DB which wouldn't connect anyway) but all others not there. So, I created them again, this time with monitor; back in Workbench I tested/saved the DB connections, rebooted apache, refreshed the test url in browser, install script loaded and at the crucial 'setup Database' bit... it took awhile but was relieved when it finally kicked into Initializing.

I don't know what happened to the databases I created in Workbench but at this point I don't care so long as I now have a method to add sites to a single Drupal core:-)

wusel’s picture

Look at my very first post:

Did you realy build two databases? Look at the web interface of your database server. Give them different names like in my link!

No comment needed!

Wusel

njwebdd’s picture

Thanks for question! I got same problem.