Connection error in Sequel - ruby

I'm trying to connect to my database on MySQL, with Sequel:
require "bundler"
Bundler.require
DB = Sequel.connect ({
adapter: "mysql2",
host: "localhost",
port: "3306",
user: "root#localhost",
password: "1234",
database: "sequel_demo"
})
I get this error:
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2-0.4.2-x64-mingw32/lib/mysql2/clien
t.rb:87:in `connect': Mysql2::Error: Access denied for user 'A2'#'localhost' (using password: YES) (Sequel::DatabaseConnectionError)
What is the problem?

Related

Symfony connect to oracle oci8

I'm on Symfony and I can't connect to a Oracle database, but I don't know why. Maybe you can help me a little.
Here my doctrine.yaml
doctrine:
dbal:
default_connection: default
connections:
default:
# configure these for your database server
url: '%env(DATABASE_URL)%'
server_version: '5.7'
charset: utf8mb4
test:
# configure these for your database server
url: '%env(DATABASE_TEST_URL)%'
driver: 'oci8'
server_version: ~
charset: utf8mb4
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
test:
connection: test
mappings:
test:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Test'
prefix: 'App\Entity\Test'
alias: Test
My .env file with 2 database:
DATABASE_URL=mysql://xxx:xxx#mysql:3306/pivot
DATABASE_TEST_URL=//user:owd#host:port/dbname
And here my controller
public function xxx() {
$entityManager = $this->getDoctrine()->getConnection('test');
$sql = 'SELECT * FROM xxx.O2_ADRESSE WHERE ROWNUM = 1';
$stmt = $entityManager->prepare($sql);
$stmt->execute();
dump($stmt->fetchAll());
}
I get the following error :
An exception occurred in driver: ORA-12505: TNS:listener does not currently know of SID given in connect descriptor
Any help on what im doing wrong?
Are you sure that the db is running?
You can check it via sqlplus, eg:
sqlplus user:password#mysql:3306/pivot
Can you update DATABASE_URL and try?
to use oracle: DATABASE_URL="oci8://db_user:db_password#127.0.0.1:1521/db_name"
https://symfony.com/doc/current/doctrine.html
https://symfony.com/doc/current/bundles/DoctrineBundle/configuration.html#oracle-db

Symfony: Doctrine - checking there's a connection

Is there a simple way to debug why Doctrine is not connecting to MySQL?
config.yml has:
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
and parameters.yml seems to have the correct connection information in it. E.g.
parameters:
database_host: 127.0.0.1
database_port: null
database_name: <my database name>
database_user: <my database user>
database_password: <my database password>
However this piece of code still echoes out "Not connected".
$cnx = $this->getDoctrine()->getConnection();
if ($cnx->isConnected()){
echo "Connected";
}
else {
echo "Not connected";
}
and I'm not getting any errors returned.
Any suggestions?
This works:
$em = $this->getDoctrine()->getManager();
$em->getConnection()->connect();
$connected = $em->getConnection()->isConnected();
$connected will be true to indicate it is connected.
The connect() establishes the connection, and then isConnected() returns a boolean to tell if it is connected.

Influxdb authentication fail using Ruby

I am trying connect to influxdb using influxdb-ruby gem.
with:
influx -username admin -password secret
> SHOW DATABASES;
name: databases
---------------
name
_internal
metrics
works fine.
But if I try with Ruby:
client = InfluxDB::Client.new(host: "host", port: 8086, database: "metrics", user:"admin", password: "secret")
client.list_databases
InfluxDB::AuthenticationError: {"error":"authorization failed"}
Any tip here ?
Thanks in advance
You must replace the user argument by username.
client = InfluxDB::Client.new(host: "host", port: 8086, database: "metrics", username:"admin", password: "secret")

REDMINE on Debian 7 doesn't send mails over Exchange

i'm running Redmine on Debian 7 and try to send mails via Mircosoft Exchange.
My configuration.yml looks like:
default:
email_delivery:
delivery_method: :smtp
smtp_settings:
enable_starttls_auto: true
address: <FIREWALLIP or SMTPIP>
port: 25
domain: <MYDOMAIN.local or mydomain.de>
authentication: :login
user_name: "username"
password: "pwd"
I used both the Firewall and smtp ips and various combinations of domains and usernames to try it.
Sending the mail via telnet works with both ips.
Can anyone help?
Thanks.
edit resolved:
works with this configuration:
default:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: <FIREWALLIP>
port: 25
domain: <mydomain.de>
works with this configuration:
default:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: <FIREWALLIP>
port: 25
domain: <MYDOMAIN.local or mydomain.de>
authentication: :login
user_name: "username"
password: "pwd"

Cant acces to MAMP after creating Database with Doctrine and Symfony2

I'm trying to get on with the Symblog Tutorial for Symfony2 (http://tutorial.symblog.co.uk/docs/doctrine-2-the-blog-model.html)
After I created my databse with php app/console doctrine:database:create I dont have acces to localhost/MAMP/ anymore?! This is the Error Message "Error: Could not connect to MySQL server!"
Can anyone help me?
Thats my config.yml
Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
unix_socket: /var/mysql/mysql.sock
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
Thats my parameters.ini
[parameters]
database_driver="pdo_mysql"
database_host="localhost"
database_port="3306"
database_name="symfony"
database_user="root"
database_password=""
The default port for MAMP server should be 8889 while you are using 3306, the error could be that.
My parameters
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: '8889'
database_name: symfony_blog
database_user: root
database_password: root
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: 7f03537e81f981683bc773b9ec7113ab5861adec
database_path: null

Resources