Copying Drupal website and transfer to another hosting and domain - php

How to copy the site on the CMS Drupal? At the moment, I just completed the export of the database, then made a copy of the site from the hosting. And uploaded to the new hosting, in the domain directory, the copied site, and through phpmyadmin imported the database. I got this error ...
Error The website encountered an unexpected error. Please try again
later. Error messagePDOException: SQLSTATE[HY000] [1045] Access denied
for user 'rvsrru_c1035'#'localhost' (using password: YES) in
lock_may_be_available() (line 167 of
/home/aufhcrw3/public_html/includes/lock.inc).

You can use this tutorial
Copy project
Create user and add permission. It's you can change on phpmyadmin
Change settings.php
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'yourdatabasename',
'username' => 'databaseusername',
'password' => 'databasepassword',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
);
Import DB. As I understand you have already done :)

You need to update the settings.php file which is located in sites/default, and add the right database connection credentials. You'll also need to search and replace any references to the old URL to the new URL in your database, but that's not the problem you're facing right now and is best addressed by another question / google search
Have you read the documentation on this? Migrating a site

#Gariko, please change database credentials in settings.php file. Update database name, database user and password of new environment. Check for host also.
After this clear cache by drush, via db tables or admin.

If who have this promblem. Reading please this is site - https://www.drupal.org/docs/7/backing-up-and-migrating-a-site/migrating-a-site
Next step. Create new user for DB in phpmyadmin or cpanel. And change setting in file - seting.php. See above!

Related

Drupal 8 Local Set Up

I am trying to import a Drupal 8 site from a git repository.
I am using Acquia Dev Desktop 2 to set it up.
But, I always get this error:
Do you know what is causing this error?
Any suggestions are greatly appreciated.
Likely your local site's database connection does not have the same settings as the one you're cloning. DevDesktop tries to access the database with with drupaluser as the username and no password.
Unless you're using Acquia Cloud and can sync your DB using DevDesktop, I would recommend exporting your remote db from the site you're cloning. Then create a new database in DevDesktop and either import the database using rsync or phpmyadmin, or instruct DD to import it from the dump file.
Then you have to tell Drupal to pick up the new database with the new credentials, so your local settings.php must contain your local database info:
$databases['default']['default'] = array(
'driver' => 'mysql',
'database' => '<yourDatabaseNameHere>',
'username' => 'drupaluser',
'password' => '',
'host' => '127.0.0.1',
'port' => 33067,
);

Drupal: PDOException: SQLSTATE[HY000] [2002] Connection refused in lock_may_be_available()

I tried installing Drupal on my local server, and everything worked fine. I installed Drupal on my localhost, and then I tried to transfer the same Drupal directory on my server using FileZilla. Changed my settings.php file in accordance to my server MySql settings as follows:
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'manas_drupal',
'username' => 'XXXXXXX',
'password' => 'XXXXXXX',
'host' => '127.0.0.1',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
);
However, when I tried accessing the website where the Drupal installation should have been present, I encounter the following error:
PDOException: SQLSTATE[HY000] [2002] Connection refused in lock_may_be_available() (line 167 of /home/manasge/manas.getevangelized.com/drupal/includes/lock.inc).
Now, line 167 of lock.inc contains the following function:
function lock_may_be_available($name) {
$lock = db_query('SELECT expire, value FROM {semaphore} WHERE name = :name', array(':name' => $name))->fetchAssoc();
if (!$lock) {
return TRUE;
}
$expire = (float) $lock['expire'];
$now = microtime(TRUE);
if ($now > $expire) {
// We check two conditions to prevent a race condition where another
// request acquired the lock and set a new expire time. We add a small
// number to $expire to avoid errors with float to string conversion.
return (bool) db_delete('semaphore')
->condition('name', $name)
->condition('value', $lock['value'])
->condition('expire', 0.0001 + $expire, '<=')
->execute();
}
return FALSE;
}
What seems to be wrong here? Everything works fine on my localhost, but I can't seem to get this thing working on my main host. For reference, this is the link where my Drupal directory is hosted: http://manas.getevangelized.com/drupal/
Also, I have an empty database named manas_drupal defined in PHPMyAdmin already. Also, I made sure that the username and password for MySQL in settings.php were entered correctly.
Check MySQL is running correctly.
This happened to me because the server that was running MySQL had killed off the process, although the specifics of why this happened are not relevant. When my instance of drupal went to connect to the database it was given 'Connection Refused'.
I then attempted to directly connect to the database but I had similar issues connecting. A thread I found here suggested restarting MySQL. When I checked the status of MySQL it gave me the following error:
$ sudo service mysql status
MySQL is not running, but lock file (/var/lock/subsys/mysql[FAILED]
After restarting it, my drupal instance worked as normal again.
Your database shouldn't be empty, export your database from localhost and import it in your empty database in your online server.

PDOException: SQLSTATE[28000] [1045] Access denied for user

I was having the same error message when starting an existing project on another computer. As the repository wasn't online already, I had to copy the whole D7 folder from PC1 to PC2, and import the database in phpMyAdmin. I've got this error as result when accessing my (localhost) homepage.
"PDOException: SQLSTATE[28000] [1045] Access denied for user '***'#'apache2-**.dreamhost.com' (using password: YES) in lock_may_be_available() (line 165 of /home/**/**.INFO/includes/lock.inc)."
Check, that user defined at your scripts created and have permissions to using database ( on copying database you transfer data, not users and permissions)
PhpMyAdmin allow do this
Or simple create new user ( look username and password at your configuration script )
I have solved my question its for help i am writing the answer for having same problem,
firstly go to your /sites/default/settings.php and simply change these files in your new site which you want to run as well as old,
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'databasenameofyournewdatabase',
'username' => 'usernameonthatserver',
'password' => 'passwordonthatserver',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
);
This error appears to me when I add my user to the MySQL Workbench and use "remember my password".
If this is your case, try editing settings.php in $databases and removing the password of your user, because it is already "remembered".

MySql Error: cannot connect to local MySql server through socket '/var/run/mysqld/mysqld.sock' (2), while other pages do connect correctly

I understand this problem has been a recurring problem on this site, but my issue is a little different than the previous ones.
PROBLEM
Some pages use the correct socket directory, while other pages try and connect through an incorrect socket directory or this is what I believe the problem is based on the error i am receiving.
DETAILS
HOST: example.com
cakePHP version: 1.3.2 (Not my choice).
Page's content comes from database.
URL: http://example.com
My website has 2 sections:
anonymous section
login section for members or admin
The anonymous section works. It accesses the database, adds the content, and funcitons as it should.
ERROR
The error occurs when I click a link "view more.." under "Job Links" on the home page. A login form should pop up, instead i receive the error "cannot connect to local MySql server through socket '/var/run/mysqld/mysqld.sock' (2)".
In addition, after I login via the "Members login" button, also on the home page, with the correct credentials, it also produces the same error.
QUESTION
Why would different sections on my webpage try to access the sockets through different directories?
ADDITIONAL STUFF
I signed up today and this is my first post, so feedback on my post regarding enough information would be helpful for future posts.
Thanks for your time.
UPDATE
Upon further research, MySql has been using the socket directory /var/run/mysqld/mysqld.sock from the start. Not sure what this means yet, but continuing research..
database.php file
class DATABASE_CONFIG {
var $default = array(
'driver' => 'mysqli',
'persistent' => true,
'host' => 'redlabelcom.netfirmsmysql.com',
'login' => 'bcp',
'password' => '********',
'database' => 'bcp',
'prefix' => '',
'encoding' => 'UTF8',
//'socket' => '/var/run/mysqld/mysqld.sock', // I've tried commenting out all variations of socket and port
//'port' => '/var/run/mysqld/mysqld.sock', // nothing works.
);
var $test = array(
'driver' => 'mysqli',
'persistent' => false,
'host' => 'redlabelcom.netfirmsmysql.com',
'login' => 'bcp',
'password' => '********',
'database' => 'bcp',
'prefix' => '',
'encoding' => 'UTF8',
//'port' => '/var/run/mysqld/mysqld.sock',
);
}
?>
This problem is really strange. I guess this has something to do with mysql connection. MySQL is a daemon, usually configured in /etc/mysql/my.cnf. There you define how the client will connect the MySQL server:
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
If your socket is wrong (there's no such socket on the server), you are probably connecting different mysql host/port from anonymous/secured parts of application. This is possible (I mean different db connections from different application parts). Check your configuration (host, port, etc.) and try to connect from MySQL console:
$ mysql -h hostname -u username -p dbname # enter password
and check if you can connect. If you can connect from console, you'll surely connect from any server-side application (php, python, whatever).
It's an application that someone else was developing, right, and now you have to maintain it?
PROBLEM SOLVED!
Thanks everyone for your support!
This was an interesting issue that initially looked more complicated than the actual problem.
cakephp version 1.3.2 is set up to make a new connection to the database if you need to access the phpbb data fields. The new connection uses a different configuration than what is set up in the database.php file.
Below is a detailed description with file locations.
the 'app/webroot/discussion/common.php' file makes a NEW connection to the database using a different set of MySql parameters than the database.php file. Again, it does NOT use database.php's MySql configuration.
Instead, cakephp defines new connection variables located at:
'app/webroot/discussion/config.php'
To solve the problem, simply change the
$dbhost => localhost -> $dbhost => yourservername
$dbname => wrongname -> $dbname => rightname
etc..
Keep in mind that it is possible the previous developer changed these values, so if this doesn't help you then good luck.
BTW, the error message above was the result of trying to connect to localhost.
To resolve this issue, I ran the following commands:
mysqld --tc-heuristic-recover=ROLLBACK
systemctl start mariadb.service

Yii Framework with CPanel: Database error when trying to access 'model' generator in gii

I got this error when trying to access 'model' and 'CRUD' generator in gii.
CDbConnection failed to open the DB connection: SQLSTATE[42000] [1044]
Access denied for user 'jivaindo_fin'#'localhost' to database
'jivaindo_finale'
The server is remote in other place. And using Cpanel to access it. the server name is 'jivcom.com'.
(i edited the file using filezilla)
The database used is MySQL.
I have checked database name, database username and password. And all is match in the Cpanel.
This is the config/main.php in the web folder. i suspect this is where i get the error but i can't find it.
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=jivaindo_finale',
'emulatePrepare' => true,
'username' => 'jivaindo_fin',
'password' => 'j1v41nd0',
'charset' => 'utf8',
),
Can anybody help me for this problem? any solution to make it able to access the 'model' generator?
Have you tried 127.0.0.1 instead of localhost in your connectionString?

Categories