Local Drupal website connecting to a remote database - drupal

I'm new to Drupal. I want to run my Drupal website locally and connect directly to the remote database, but I can't seem to figure out how to do it. I have MAMP installed on the Mac and I have all the files in the htdocs folder. It looks like I just need to change the settings.php file to match my remote database, but I'm unsure what I need to change.

I guest you look at this drupal.org HowTo that step by step guides you through creating the database and what you need to change before running the Install program.
https://www.drupal.org/node/66187
Also check the comments on that thread.

Yes, you have to adjust your settings file (/sites/default.settings.php), database configuration. Watch out, usually there is a different ("external") host for accessing database from out of server. I think that it can be set per database user does it has privileges to access database from outer server or not. Maybe there's some special user for that.

There should not be any extra setup or configuration. Just make sure that
You are connected to the remote database (usually goes in sites/default/settings.php).
The database host allows remote connections.

Related

Database error installing WordPress on Ubuntu

I am trying to install WordPress on Ubuntu.
I have installed mysql and created a database and granted a new user permission to use it, but when I visit the domain linked to the server it asks me for the database information and then says it is invalid.
I have double-checked this information, so does anyone have any suggestions why this is happening?
I visit the domain linked to the server it asks me for the database
information and then says it is invalid.
When this happens, most probable reasons would be.
The actual database and schema may be unavailable.
So first check if the database table is available to you. This can be done through command line, phpmyadmin, or database clients like MYSQL Workbench. Try accessing your database. If the schema is available and accessible to you, then surely wordpress too can connect to it.
You have mentioned that you are trying to access the domain name, and enter credentials, which means you are trying to install via graphical user interface, as against editing wp-config.php file via ssh. So, if if you have passed the step 1, try to check if the file system is writable. Read this article for setting correct file permission. https://wordpress.org/support/article/changing-file-permissions/
Also you can include some screenshots, and add more information on the type of server configuration(apache/nginx, php, mysql versions, port configurations) you use, and the type of installations you performed.

How to make subdomain from ip using a php form

I want to have a form on my website so users can make a subdomain for their game server so like if the ip for the server is
192.168.1.132 then they put it into a form and they make a name for the subdomain
and then they can use this to join their server name.domain.com:76651
I'm Mitch from Shockbyte - and the creator of the subdomain creation tool you linked to.
The subdomain creation tool on Shockbyte uses an API that can be purchased at: https://shockbyte.com/billing/cart.php?a=add&pid=34
This includes the PHP files to add the subdomain creator to your own website. This is the system that Shockbyte uses, as well as pretty much every host that has a subdomain creator tool on their website.
If you wish to create your own tool with PHP instead of using the system above, you will need more than just a PHP script.
You will need to be running a DNS server to create the records on. The most popular is probably BIND.
Once you have a DNS server running, then you can write a PHP script to manipulate the records. It will depend on which DNS server you use, but there may be an API available or if you're using a database such as MySQL, then you may be able to directly query the database.

Restore WordPress site without DB backup?

I'm trying to restore a WordPress website for which I have the files backup, but I don't have a DB backup on hand.
I managed to get the site up partially by restoring the backup in cPanel - all the site's pages are working now, but because there is no DB in place (wp-config.php points to what 'used to be' my DB) accessing site.com/wp-admin renders this error:
Error establishing a database connection
This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at localhost. This could mean your host's database server is down.
Are you sure you have the correct username and password?
Are you sure that you have typed the correct hostname?
Are you sure that the database server is running?
If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.
I know I made a huge mistake by not backing up my website DB.
Is there any way to be able to access wp-admin in this case? Can't I 'mock' the old DB with a new one? Anything to be able to access wp-admin.
Configure a core Wordpress with fresh installation point your current Wordpress files to the new database just got created
You should copy all the settings (from DB_NAME,DB_USER,DB_PASSWORD......AUTH_KEY,SECURE_AUTH_KEY..... till table_prefix) from your new installation wp-conf to old one
You would have lost almost all data stored in db like users etc however if your theme was more file based you should be able to se pages up
This is Triel and i think it should work to bes extent dont see any other way out of this scenario.
"Can't I 'mock' the old DB with a new one? Anything to be able to access wp-admin"
Simply Create a new mysql DB on your server and put its info in your wp-config.php file.

Share my local wordpress site with another developer with git

I want to share my local wordpress site with another developer with git in a way our database will be same when he setups my wordpress site in his local PC.
I am using windows 7 OS
I'm not sure if what you are asking for is possible.
here is my suggestion (the database should be on a real server)
if you use CPanel:
1- In the CPanel create the database and new user and assign the user to the database
2- In the CPanel Go to Remote MySQL, add your IP address and the other developer IP address. (to allow remote access)
3- Export the database from your local PC and import it to the CPanel.
4- Change the wp-config.php configuration.
Note: The urls should be the same on your PC and the developer pc.
for example if your website url on your pc is : http://localhost/mywebsite/
the other developer should make it the same.
I would suggest keeping your database out of git (except perhaps the database definitions).
Instead you can leverage git hooks. Using something like pre-push, run a mysql dump command to get the current state of your db, and copy it to a shared Dropbox/Drive folder with your team mate.
.git/hooks/pre-push
#!/bin/bash
mysqldump -u root -p --all-databases > ~/Dropbox/shared-with-tm/mysql.sql
Completely untested This is a vague answer to answer a vague question - but might give you a starting point.

Wordpress Dev Environment Migration

I've tried looking around for a guide on moving a wordpress site into a dev environment, but all of the guides I've seen have been about CREATING one, as opposed to my situation, where I need to move an existin site to a local VM to create a dev/testing environment.
I'm fairly well-versed on how to create a dev environment from a regular old website, but just about everything wordpress-related gets me confused somehow.
Where I am now:
I've created a CentOS 6.0 VM using VMware on a Windows 7 machine. I've installed PHP, Apache, MySQL, and FTP-Server, along with all of the required updates and such. I have disabled SELinux.
I've moved the contents of the var/www/html/ folder from the live (production) server over to the var/www/html/ folder on my VM (currently exists within /var/www/html/my-website/)
My current issue:
When I attempt to access localhost/my-website/ I'm getting "Error establishing a database connection". An attempt at localhost/my-website/wp-admin/ tells me that either the database server is down (do I have to start this separately?) or that the username and/or password information in wp-config.php is incorrect (this was all simply moved from one place to another).
Any assistance would be greatly appreciated.
Have you updated wp-config.php to include your localhost and database info for your local dev environment?
I bet wp-config.php is still pointing to your remote server DB which the MySQL DB wont allow for external connections
Also, make sure that the dev is using the same domain as the live version. On my windows machine, I do this by changing my hosts file. I'm sure there is something similar on your VM.
If I am unable to do this and I need the dev version to be under a different domain I would do the following.
Create mysqldump of live database
Edit the dump and replace
all occurrences of livedomain.com with devdomain.com (if you dont do
this at least check the wp_options table for the livedomain.com
occurences.
Change wp-config.php database settings.
I always ensure to use the same domain (controlled by local hosts file), and same db config in my dev environment as in my live environment.
If you've not changed the wp_options table for (option_name = siteurl or option_name = home), then chances are if you type in devdomain.com into your browser it will redirect to newdomain.com
Hope this helps
Blake
I know this was been answered but just to be perfectly clear:
on Centos6 you need to run httpd with php, and the mysql server. In the mysql server you have to import the database dump from the live website then you have to edit the config in wordpress to match the username and password on wordpress.
now when moved the db does not keep the username and password so I suggest you do this
commands to be run in shell:
service mysqld start
chkconfig mysqld on
that will take care of the db server running
then edit wp-config with username root and no password (I am pretty sure you have not added a password at mysql-server install)
post in here if you need further help.

Resources