Drupal 8 Local Set Up - php

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,
);

Related

Typo3 with MSSQL [duplicate]

I tried to install TYPO3 (8.7.7) on my Webserver (IIS) and I'd like to use my SQL Server instead of MySQL.
I found lots of instructions how to make this (on typo3.org and other websites) but none of these worked for me.
I found out, that I must install two extensions before I start the installation (ADOdb & DBAL). Probably there is my fault.
Can anybody explain step by step how to install these extensions before the TYPO3 installation?
I'm using the following configuration to successfully run TYPO3 on SQL Server on my local windows machine:
'DB' => [
'Connections' => [
'Default' => [
'charset' => 'utf-8',
'dbname' => 't3',
'driver' => 'sqlsrv',
'host' => 'localhost',
'password' => 'yourPassword',
'port' => 1433,
'user' => 'sa',
],
],
],
It's a bit complicated to set up with the installer as it is not yet "clickable". What you can do is call the install script and when it's asking you to configure the database connection you go to your file system and manually add the config section above (with your connection params of course) in the LocalConfiguration.php file.
Then reload the installer - which should now recognize the configured database connection and let you go to the last step where you can import / create the base tables and data.
Note: At the moment I know of two bigger areas where SQL Server is still a problem with TYPO3 8.7 - that's workspaces and database compare. The last one means that after you have existing data in your SQL Server tables won't let you alter them via the TYPO3 database compare tool - you have to change tables manually if you need to.
Find a gist of the table create statements on https://gist.github.com/psychomieze/9570ea1f578aee7a1fbb68c3240a21c8
With 8.7, Doctrine DBAL has been integrated into the core and ADOdb & DBAL sysexts have been removed as there is no need anymore.
Take a look at the documentation of Doctrine DBAL http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html and it should fit perfectly to the configuration of the DB in `LocalConfiguration.php``
'DB' => [
'Connections' => [
'Default' => [
'charset' => 'utf8',
'dbname' => 'typo3',
'driver' => 'mysqli',
'host' => 'mysql',
'password' => 'dev',
'port' => 3306,
'user' => 'root',
],
],
],
Now my Typo3 is working.
I solved my problem a little bit complicated.
I made a test environment and installed Typo3 with MySQL.
Then I copied the database with the "Microsoft SQL Server Migration Assistant 7.6 for MySQL"
(https://www.microsoft.com/en-us/download/details.aspx?id=54257) to my main environment.
After that I copied all the created folders (typo3conf, typo3temp etc.) to my main environment
and edited the databaseconnection in the LocalConfiguration.php file like Georg Ringer proposed.
When I am installing Typo3 and MSSQL next time I will do it like susi proposed.
Thanks for your help.

How do I make my Laravel project on Heroku use Heroku Postgres?

I have been working on a project that requires I set it up in Heroku. The Database I have been using thus far locally is mySQL, but I am looking to use Postgre when the project is on Heroku.
I have done a large amount of searching but have yet to find an answer as to how I configure my Laravel project to use Postgres and how do I perform basic functions such as adding a new database to Postgres.
If there is an alternative way to just use mySQL as is that would be great.
Thanks for the help.
Heroku places (once you provision a Heroku Postgres instance) the database credentials in the DATABASE_URL environment variable, in the following format:
postgres://username:password#hostname:port/database
Now, you could manually fill out your DB_HOST, DB_USERNAME, etc. .env vars from this, but there's a better way: you can parse the URL in your config/database.php file.
Note: Newer versions of Laravel now support a DATABASE_URL .env value directly. No need to parse anymore.
'pgsql' => [
'driver' => 'pgsql',
'host' => parse_url(env('DATABASE_URL'), PHP_URL_HOST),
'port' => parse_url(env('DATABASE_URL'), PHP_URL_PORT),
'database' => ltrim(parse_url(env('DATABASE_URL'), PHP_URL_PATH), '/'),
'username' => parse_url(env('DATABASE_URL'), PHP_URL_USER),
'password' => parse_url(env('DATABASE_URL'), PHP_URL_PASS),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
],
(Make sure you set DB_CONNECTION to pgsql so this connection is used!)
how do I perform basic functions such as adding a new database to Postgres
You don't. A Heroku Postgres instance comes with one database.

Copying Drupal website and transfer to another hosting and domain

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!

Where does php+laravel reads db connection string because runtime defaulting to user id not defined anywhere in my app?

I am hosting my php+laravel rest API application in azure app service (windows). The app server comes with 'mysql in app' (build into it). I am able access the mysql database through myphpadmin. I can see there were two predefined users, one is root and another one is azure. To connect to database using myphpadmin, it uses azure user id.
In my application in .env I have DB_USERNAME set to azure and in database.php, if the user id is not found in config default it is set to default to 'azure'. Also in azure app server's app setting I have all the connection strings defined and there as well, I am using azure as the DB_USERNAME.
But when I ran postman to one of the end point, I noticed, the end point is failing because of "Access denied for user 'root'#'localhost'". I am really confused where would my application uses root as the username instead of azure.
Thanks
Remember to run php artisan config:cache command when you change any data in env
laravel always read config data from its cache.
so if your .env credentials are changed in server you also have to cache again that credentials
also make sure that your database config file reading all the credentials from .env by default.
Example:
'mysql' => array(
'driver' => 'mysql',
'host' => env('DB_HOST','localhost'),
'database' => env('DB_DATABASE','billing'),
'username' => env('DB_USERNAME','root'),
'password' => env('DB_PASSWORD', '1234'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
)
Note:
If you execute the config:cache command during your deployment
process, you should be sure that you are only calling the env function
from within your configuration files. Once the configuration has been
cached, the .env file will not be loaded and all calls to the env
function will return null.
You also need to configure it not just in .env as #EmtiazZahid has suggested to you, and you must restart your server each time you do any configuration in .env

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

Categories