DSN in Config.xml

27 views
Skip to first unread message

AMR

unread,
Jan 6, 2019, 5:32:16 AM1/6/19
to Fat-Free Framework
Hello

I'm new to F3 and currently playing with CSM demo. 

I try to convert from SQLite to MYSQL but not really sure how to add MySQL DSN in config.ini. Can somebody help me?


; Site description
site
="CMS Demo"
; SQLite DSN
;db="sqlite:db/cms.db" <-- original line
db
="mysql:host=localhost;port=3306;dbname=b" ;<-- new line.. stuck here.

Thank a bunch!

ikkez

unread,
Jan 7, 2019, 8:09:55 AM1/7/19
to Fat-Free Framework
well the DSN string looks good. Can you specify the problem or whats the error you have?

ved

unread,
Jan 7, 2019, 8:44:24 AM1/7/19
to Fat-Free Framework
Unlike SQLite:

$f3->set('DB', new DB\SQL('sqlite:/absolute/path/to/your/database.sqlite'));

MySQL will most likely require you to supply a username and password:

$db=new DB\SQL(
    'mysql:host=localhost;port=3306;dbname=mysqldb',
    'admin',
    'p455w0rD'
);

So the issue probably isn't on the DSN format but with the DB\SQL call that isn't supplying a username and password if you're just simply replacing the DSN without any more changes.

See the docs: 
Reply all
Reply to author
Forward
0 new messages