Creation of a new database

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
morzol
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 14.02.2008, 21:28
Location: Czech Republic

Creation of a new database

Post by morzol »

Hi,

I found some tutorial how to create a new database on Firebird :

ZConnection1.Database := 'd:\db1.fdb';
ZConnection1.Protocol := 'firebird-1.5';
ZConnection1.Properties.Add ('CreateNewDatabase=CREATE DATABASE ' +
QuotedStr ('d:\db1.fdb') + ' USER ' +
QuotedStr ('sysdba') + ' PASSWORD ' + QuotedStr ('masterkey') +
' PAGE_SIZE 4096 DEFAULT CHARACTER SET ISO8859_1');
ZConnection1.Connect;

Does similar way is valid for MySQL as well. Especially I mean a row with command ZConnection1.Properties.Add( ....) ?

Any help how to create a new database on MySQL server a connect to it is appreciated.

Thanks.

Marian
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Just connect to the server using a user which has sufficient rights to create a database. It's easiest if you can connect to a database that already exists (eg. database mysql when connected as root), but using the property 'dbless=true' that's not necessary.
Once connected you can fire a normal query : 'create database <dbname>;' that's it.
To fire this query : put a TZQuery component in your form. set SQL.text property to the query string and call execSQL method.
When using Testing branch/snapshot it's even easier : use TZConnection.ExecuteDirect(SQL:string):boolean

Mark
Image
Post Reply