Connect to mysql server through ssl in Zend Framework - mysql

Single DB connection (resource configuration) from application.ini:
resources.db.adapter = "pdo_mysql"
resources.db.params.host = "mysql1"
resources.db.params.username = "dbuser"
resources.db.params.password = "dbpass"
resources.db.params.dbname = "dbname"
;resources.db.???
Multiple DB connection (resource configuration) from application.ini:
resources.multidb.mysql1.adapter = "pdo_mysql"
resources.multidb.mysql1.host = "mysql1"
resources.multidb.mysql1.username = "dbuser"
resources.multidb.mysql1.password = "dbpass"
resources.multidb.mysql1.dbname = "dbname"
;resources.multidb.mysql1.???

I don't believe connecting to MySQL with SSL is currently supported in Zend. However, Zend Issue Tracker ticket #6140 may be of help to you.

Related

How to config slick 3.2 connect to mysql by typesafe config package?

I have attempted official document for postgresql and change org.postgresql.ds.PGSimpleDataSource to slick.driver.MySQLDriver$
dataSourceClass = "slick.driver.MySQLDriver$"
properties = {
databaseName = "mydb"
user = "user"
password = "password"
}
numThreads = 10
scala code:
val config = DatabaseConfig.forConfig[JdbcProfile]("slick.mysql.local")
Output error:
Exception in thread "main" com.typesafe.config.ConfigException$Missing:
No configuration setting found for key 'slick.mysql.local.profile'
Seems it need a profile property but what value should be added?
============UPDATE========
config properties are under brackets:
slick.mysql.local {
dataSourceClass = "slick.driver.MySQLDriver$"
properties = {
databaseName = "mydb"
user = "user"
password = "password"
}
numThreads = 10
}
If you carefully read the docs, what they say is:
define a mydb key in some application.conf with your configuration
refer to that configuration using val db = Database.forConfig("mydb")
So I can only assume you're missing your slick.mysql.local key.
I also found it difficult to configure the database connector. Here is my config:
mysql {
dataSourceClass = "com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
properties = {
url = "jdbc:mysql://127.0.0.1:3306/dbName"
databaseName = "dbName" <= maybe not necessaray as also in the url
user = "root"
password = ""
}
numThreads = 10
}
Thanks to https://groups.google.com/forum/#!topic/scalaquery/WbR6yHzBj_8
I struggle some days and find a config can works.
driver = "slick.driver.MySQLDriver$"
db {
url = "jdbc:mysql://127.0.0.1:3306/develop_tdsystem?user=user&password=password"
driver = com.mysql.jdbc.Driver
maxThreads = 10
}
please notice there are some warning:
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
[warn] c.z.h.u.DriverDataSource - Registered driver with driverClassName=com.mysql.jdbc.Driver was not found, trying direct instantiation.

Connecting MySQL to Scala using slick

I am trying to connect MySQL database do scala application using slick 3.1
In demo which is provided by Typesafe, this code is used as application.conf :
h2mem1 = {
url = "jdbc:h2:mem:test1"
driver = org.h2.Driver
connectionPool = disabled
keepAliveConnection = true
}
I am running MySQL database on ampps apache server and now I am confused regarding what to enter as url and driver so that my application can connect to database?
Should my url be "localhost"?
Something like this:
database = {
url = "jdbc:mysql://localhost/test"
user = "user"
password = "pwd"
driver = com.mysql.jdbc.Driver
connectionPool = disabled
keepAliveConnection = true
}

Connecting to mysql using Sequel on Openshift

I'm developing a site using Cloud9 with Ruby and Sinatra and I'm deploying to Openshift. I have set up cartridges for mySQL and PhpMyAdmin. The problem I'm having is connecting to the database using Sequel.
Here's what I have
DBS = Sequel.connect('mysql://OPENSHIFT_MYSQL_DB_USERNAME:OPENSHIFT_MYSQL_DB_PASSWORD#OPENSHIFT_MYSQL_DB_HOST:OPENSHIFT_MYSQL_DB_PORT')
heros = DBS[:superheros]
get '/mysql' do
"#{heros.first[:name]}"
#"mysql"
end
I've also tried
db_user = ENV['OPENSHIFT_MYSQL_DB_USERNAME']
db_pass = ENV['OPENSHIFT_MYSQL_DB_PASSWORD']
db_host = ENV['OPENSHIFT_MYSQL_DB_HOST']
db_port = ENV['OPENSHIFT_MYSQL_DB_PORT']
DBS = Sequel.connect('mysql://#{db_user}:#{db_pass}##{db_host}/#{db_port}')
All I'm getting back is Internal Server Error
Can anyone please provide me with some tips on how I can connect?
Thanks
DBS = Sequel.connect('mysql://#{db_user}:#{db_pass}##{db_host}/#{db_port}')
How to connect to DB with Sequel
Port and host are separated via "/", but should be ":" (colon)
You forgot database name.
Example of correct connection string:
mysql://user:password#host:port/database
Try something like that
db_user = ENV['OPENSHIFT_MYSQL_DB_USERNAME']
db_pass = ENV['OPENSHIFT_MYSQL_DB_PASSWORD']
db_host = ENV['OPENSHIFT_MYSQL_DB_HOST']
db_port = ENV['OPENSHIFT_MYSQL_DB_PORT']
db_name = ENV['OPENSHIFT_APP_NAME']
DBS = Sequel.connect('mysql://#{db_user}:#{db_pass}##{db_host}:#{db_port}/#{db_name}')
Thanks, I tried all sorts of permutations but in the end this worked
db_user = ENV['OPENSHIFT_MYSQL_DB_USERNAME']
db_pass = ENV['OPENSHIFT_MYSQL_DB_PASSWORD']
db_host = ENV['OPENSHIFT_MYSQL_DB_HOST']
db_port = ENV['OPENSHIFT_MYSQL_DB_PORT']
DBS = Sequel.connect(:adapter=>'mysql', :host=>db_host, :database=>"prescreen", :user=>db_user, :password=>db_pass)

Getting "Server Error" when click on "New Account" in gerrit

I am getting server error when i am try to register new user at first time. It works fine if i configure with H2 database.
My gerrit.config file is :
[gerrit]
basePath = git
canonicalWebUrl = http://localhost:8081
[database]
type = mysql
database = reviewdb
hostname = localhost
username = gerrit
[index]
type = LUCENE
[auth]
type = DEVELOPMENT_BECOME_ANY_ACCOUNT
[sendemail]
smtpServer = localhost
[container]
user = gerrit
javaHome = /usr/lib/jvm/java-7-openjdk-amd64/jre
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = http://*:8081/
[cache]
directory = cache

Asterisk 1.8 cdr-adaptive mysql

i'm having a little problem. I'm using Debian and I got asterisk 1.8 and I want to use CDR along with mysql.
In Asterisk 1.8 you apparently gotta use cdr-adaptive module instead of the regular. That is just what I did. Now I have 1 error when I "module reload cdr_adaptive_odbc.so" and I can't solve it :
WARNING[23172]: cdr_adaptive_odbc.c:123 load_config: No such connection 'MySQL-asterisk' in the 'adaptive-connection' section of cdr_adaptive_odbc.conf. Check res_odbc.conf.
Now here are all the files related, I can't understand what is wrong :
/etc/odbc.ini :
[MySQL]
Description = MySQL ODBC MyODBC Driver
Driver = /usr/lib/libmyodbc3.so
FileUsage = 1
[Text]
Description = ODBC for Text Files
Driver = /usr/lib/libodbctxt.so
Setup = /usr/lib/libodbctxtS.so
FileUsage = 1
CPTimeout =
CPReuse =
[PostgreSQL]
Description = PostgreSQL driver for Linux & Win32
Driver = /usr/lib/libodbcpsql.so
Setup = /usr/lib/libodbcpsqlS.so
FileUsage = 1
[DB2]
Description = DB2 Driver
Driver = /opt/IBM/db2/V8.1/lib64/libdb2.so
FileUsage = 1
DontDLClose = 1
DMEnvAttr = SQL_ATTR_UNIXODBC_ENVATTR={DB2INSTANCE=db2inst1}
[MySQL-asterisk]
Description = MySQL asterisk database
Driver = MySQL
Socket = /var/run/mysqld/mysqld.sock
Server = localhost
User = root
Password = XXXXX
Database = ics
Option = 3
/etc/asterisk/cdr_adaptive_odbc.conf :
[adaptive-connection]
connection = MySQL-asterisk
table = cdr
alias start => calldate
/etc/asterisk/res_odbc.conf :
[Asterisk]
enabled => yes
dsn => MySQL-asterisk
username => root
password => XXX
;pooling => no
;limit => 0
pre-connect => yes
This is what I get when i check the cdd status :
Call Detail Record (CDR) settings
----------------------------------
Logging: Enabled
Mode: Simple
Log unanswered calls: No
* Registered Backends
-------------------
Adaptive ODBC
cdr-custom
ODBC
csv
radius
res_config_sqlite
And this is what I get when i check de odcb
ODBC DSN Settings
-----------------
Name: Asterisk
DSN: MySQL-asterisk
I can't figure out what's wrong. Anyone has an idea ?
I assume you've fixed this now. I ran into a similar issue and the problem stemmed from the documentation. It refers to connection= in cdr_adaptive_odbc.conf being the DSN name. It's the name you want and not the DSN. So in your case:
connection = Asterisk
then at the command line do a
CLI> module reload cdr_adaptive_odbc.so
and you should see a screenfull as Asterisk finds the tables and does any mappings you have specified.