Hello i have an localhost wordpress project. The last thing i need to do is connect a database. Because i get an message in my browser that there is no Error establishing a database connection. Can anyone tell me step-by-step how to do this? This beneath is where the dev.js for asks. My project runs on Node.js
$GLOBALS['DB_HOST'] = 'localhost';
$GLOBALS['DB_NAME'] = 'name';
$GLOBALS['DB_USER'] = 'username';
$GLOBALS['DB_PASSWORD'] = 'password';
$GLOBALS['DB_TABLE_PREFIX'] = 'prefix_';
Related
I am running into the error:
Error: P1001: Can't reach database server atlocalhost:5432`
Please make sure your database server is running at localhost:5432.
`
I am trying to use the command "npx prisma migrate dev" however it continueously throws the error stated above.
schema.prisma file:
datasource db { provider = "postgresql" url = env("DATABASE_URL") }
.env file:
DATABASE_URL="postgresql://[username]:[password]#localhost:5432/[db]?schema=public"
Any help or insight as to how to fix this error would be greatly appreciated!
I'm trying to have a SQL Server Docker container run and have a database backup file restored using Terraform. So far I can get the SQL server Docker image to download and run as a container but I can't get the sqlcmd to run inside the container. I have it set up where the sqlcmd runs automatically when the container starts. This is the log message I get in the container:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2749.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
SQL Server 2019 will run as non-root by default.
This container is running as user mssql.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
This is my terraform file:
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "2.16.0"
}
}
}
provider "docker" {
host = "npipe:////.//pipe//docker_engine"
}
resource "docker_image" "mssql" {
name = "mcr.microsoft.com/mssql/server:2019-latest"
keep_locally = true
}
resource "docker_container" "mssql" {
image = docker_image.mssql.latest
name = "sqldatabase"
attach = false
rm = false
restart = "no"
command = [ "/opt/mssql-tools/bin/sqlcmd", "-S localhost", "-U mssql", "-P <StrongPassword>" ]
env = [
"ACCEPT_EULA=Y",
"MSSQL_SA_PASSWORD=<StrongPassword>"
]
ports {
internal = 1433
external = 1433
}
}
I'm following this Microsoft tutorial about restoring a SQL Server database in a Docker container: https://learn.microsoft.com/en-us/sql/linux/tutorial-restore-backup-in-sql-server-container?view=sql-server-ver15
Right now I'm just trying to run sqlcmd in the container to see if it works then I'll try restoring an actual database backup. How do I get the sqlcmd to work? I'm brand new to Terraform.
UPDATE:
As #Nick.McDermaid suggested, I ran the sqlcmd manually in the container and it worked. Also the username I had was wrong. It should be SA, not mssql. I got throw off because in the container log it says This container is running as user mssql. which must be different from a SQL Server username.
As #AlwaysLearning suggested it is a timing issue, Terraform starts the Docker container and runs sqlcmd when SQL Server is not ready.
I guess I need some kind of entrypoint.sh file that Terraform can run.
Please replace
command = [ "/opt/mssql/bin/sqlservr","--accept-eula"]
I'm currently migrating our CI/CD pipeline from a Bitbucket/Jenkins environment to hosted GitLab with additional custom gitlab-ci runners. So far anything seems fine, except when it comes down to services, especially regarding MSSQL server.
I've setup a gitlab-ci.yml file, which contains a service and a build stage job which basically just executes some msbuild targets.
I call the AttachDatabase target which then internally connects to the database and prepares anything for unittesting. Unfortunately I'm not able to connect to the database, whether I alias the service or not.
According to the documentation, I should just be able to use the alias name defined in services in my connection string found in Library.Build.Database.targets to connect to the databse.
I've setup a small reference project which ilustrates the problem: mssql-test.
If the pipeline is run the following error message is shown in the log:
error : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections
image: "mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019"
variables:
PROJ_NAME: MSSQL.Test.proj
MSBUILD_BIN: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\msbuild.exe'
NUGET_BIN: 'C:\Program Files\NuGet\nuget.exe'
ACCEPT_EULA: 'Y'
sa_password: Unit-T3st3r
services:
- name: advitec/mssql-server-windows-developer
alias: mssql
attachdatabase:
stage: build
tags:
- windows-1809
- 3volutions
- docker-windows
cache:
paths:
- packages
before_script:
- cmd /C "$NUGET_BIN" restore .\packages.config -OutputDirectory .\packages
allow_failure: false
script:
- cmd /C "$MSBUILD_BIN" "$PROJ_NAME" -t:AttachDatabase -v:Minimal "-p:Configuration=ReleaseForTesting;UniqueBuildNumber=$CI_PIPELINE_IID"
I'm running a custom windows Gitlab runner (just for performance reasons), below the according config.toml
Runner:
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "gitlab-runner-02-windows-server-datacenter-1809"
url = "https://gitlab.com/"
token = "****"
executor = "docker-windows"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.docker]
tls_verify = false
image = "mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["c:\\cache"]
shm_size = 0
Any ideas what I'm missing?
Cheers
I'm accessing Cloud SQL from App Engine in the same project. I have set the password to the root user. I'm able to connect from mysql command line remotely thusly:
C:>mysql -u root -h xxx.xxx.xxx.xxx -p <- IP address of my Cloud SQL
Enter password: <--- I supply passw0rd
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 20913
Server version: 5.7.14-google-log (Google)
However, when I try from App Engine:
Code snippet:
url = "jdbc:google:mysql://myproject:us-central1:myinst/mydb?user=root;password=passw0rd";
conn = (Connection) DriverManager.getConnection(url);
The error I get is:
com.google.gae.server.Connect getConnection: ERROR. Could not get connection. Access denied for user 'root;password=passw0rd'#'cloudsqlproxy~xxx.xxx.xxx.xxx' (using password: NO)
I have tried the url with just the user only, but no luck.
Appreciate any suggestions.
Found my error. The Java URL should have been:
url = "jdbc:google:mysql://myproject:us-central1:myinst/mydb?user=root&password=passw0rd";
I replaced the ; with &.
Works now.
I've created a Java application with a Database running on Derby 10.10.2.0 (JDK 1.7 )
The problem is when NetBeans 7.3.1 is opened and the Database is connected everything works fine .
But when I compile and build this application then go to dist folder inside NetBeans Projects , I run the application and the database won't connect .
This is the code to connect to the Database :
String url = "jdbc:derby://localhost:1527/reflet;create=true";
String driver = "org.apache.derby.jdbc.ClientDriver";
String userName = "root";
String password = "admin";
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url,userName,password);
conn.close();