Page 1 of 2

Crear DB de MariaDB

Posted: Wed Nov 06, 2019 6:52 pm
by jorge.posadas
Grupo

¿Cómo puedo crear, desde mi aplicación, una base de datos en MariaDB, PEROOO en un directorio que yo desee?


De antemano muchas gracias

Re: Crear DB de MariaDB

Posted: Wed Nov 06, 2019 10:52 pm
by dragancesu
Easy or hard, it depends how you think

Best from some database management program, I use HeidiSQL

The principle is to create a database and tables that you use from the application

CREATE DATABASE [IF NOT EXISTS] database_name
[CHARACTER SET charset_name]
[COLLATE collation_name]

http://www.mysqltutorial.org/mysql-create-database/

CREATE TABLE [IF NOT EXISTS] table_name(
column_1_definition,
column_2_definition,
...,
table_constraints
) ENGINE=storage_engine;

http://www.mysqltutorial.org/mysql-create-table/

And forget the folder, the data is written to the database, and it is somewhere in the installation, like \ProgramData\MySQL\MYSQL Server x.x\data
and folders is database nama with data definition, but all data is in file ibdata1 if use InnoDB storage engine, recommanded

x.x = mysql version

Re: Crear DB de MariaDB

Posted: Wed Nov 06, 2019 10:57 pm
by dragancesu
The first step is to install the database software

The second step is to create a database and tables

Data is transmitted through export (result is file like dbname.sql), import is start export file ( dbname.sql )

Re: Crear DB de MariaDB

Posted: Thu Nov 07, 2019 2:22 am
by Ismach
Bueno crearlo es facil pero no podras levantarlo como servidor tan facilmente
porque necesitas reinciar y orientar el que es DATADIR al servidor, NO funciona como en DBFs
aqui hay un servidor o servicio que usa LOCATION --> DATADIR, mas alla de los privilegios de los usuarios
solo accede a las bases de datos que levante o se pase por parametros a "mysqld.exe"

Para cada servidor necesitas otientar DATADIR

Code: Select all

"datadir=C:/Mariadb/data"     --> my.ini
Enel caso de que tengas varias Bases de Datos en distintos DATADIR solo tendras acceso a las Bases que esten en el directorio DATADIR

1) levantar elservidor y orientar aldirectorio donde quieras...:

Code: Select all

ccSQL :="C:/Mariadb/bin/mysqld --basedir=C:/Mariadb/" --datadir=C:/IsmaCh/dbLaNena/"
RUN (ccSQL)
2) ejecutar elscript .sql

Code: Select all

ccSQL :="C:/Mariadb/bin/mysql -h localhost -u root -p < C:/IsmaCh/dbLaNena/CreateMaridb.sql"
RUN (ccSQL)
Espero te Sirva
Saludos

Re: Crear DB de MariaDB

Posted: Thu Nov 07, 2019 8:17 am
by dragancesu
I see you know MySQL and how it works, i dont do that

I view MySQL as a server I access from the program, I don't care where the data is physically located (which can be easily seen)

For data preparation I use something simple, like Uniserver, create database and tables, then export and upload to server (thru HeidiSQL)

Uniserver is wapm server, https://www.uniformserver.com/, start only MySQL service and work only like localhost

Re: Crear DB de MariaDB

Posted: Thu Nov 07, 2019 3:23 pm
by Ismach
El directorio default de MySQL Y Mariadb es \data\
pero eso se puede cambiar definitivamente o temporalmente
para ello solo hay que orientar el DATADIR
en mysql my.Ini en c:\mysql\bin\
en mariadb my.Ini pero en el directorio DATADIR default c:\mysql\data\

para reorientar el DATADIR se parametriza al momento de levantar o arrancar
el servidor mysqld.exe

en Mariadb es mas completo porque hay separacion de herramientas

INSTALLDB
INITDB
CREATEDB
STARTDB

en mysql es casi todo junto

Re: Crear DB de MariaDB

Posted: Thu Nov 07, 2019 8:59 pm
by Ismach
;) ;) ;) ;) ;)
Start Server Mariadb in other data dir:

1) Create Start.inOther.Dir.bat with

Code: Select all

SET PATH=c:\Mariadb\bin\
mysqld -h localhost -u root -p --datadir=c:\Desarrollo\NuevaData\

Code: Select all

C:\Desarrollo>dir Start.inOther.Dir.bat
 Volume in drive C is Windows
 Volume Serial Number is AE19-0440

 Directory of C:\Desarrollo

07/11/2019  17:52               687 Start.inOther.Dir.bat
               1 File(s)            687 bytes
               0 Dir(s)  183.461.584.896 bytes free

C:\Desarrollo>
2) Run Start.inOther.Dir.bat

Code: Select all

C:\Desarrollo>Start.inOther.Dir.bat
2019-11-07 17:52:43 0 [Note] mysqld (mysqld 10.3.9-MariaDB) starting as process 29648 ...

3) Verificar

Code: Select all

C:\Desarrollo>cd NuevaData

C:\Desarrollo\NuevaData>dir
 Volume in drive C is Windows
 Volume Serial Number is AE19-0440

 Directory of C:\Desarrollo\NuevaData

07/11/2019  17:52    <DIR>          .
07/11/2019  17:52    <DIR>          ..
07/11/2019  17:52            16.384 aria_log.00000001
07/11/2019  17:52                52 aria_log_control
07/11/2019  17:52             2.397 ELNW00005558.err
07/11/2019  17:52        12.582.912 ibdata1
07/11/2019  17:52             1.010 ib_buffer_pool
07/11/2019  17:52        50.331.648 ib_logfile0
07/11/2019  17:52        50.331.648 ib_logfile1
               7 File(s)    113.266.051 bytes
               2 Dir(s)  183.461.371.904 bytes free

C:\Desarrollo\NuevaData>
y Good Show!!!!
:lol: :lol: :lol: :lol: :lol: :lol:

Re: Crear DB de MariaDB

Posted: Fri Nov 08, 2019 9:25 am
by mol
Is it possible to create portable installation of MariaDB?

Re: Crear DB de MariaDB

Posted: Fri Nov 08, 2019 1:01 pm
by Ismach
:o :o :o :roll: :roll:
La verdad nunca se me habia ocurrido, pero creeria que si, no se si las ultimas versiones y en win10
poque ahi el censado del window defender y herrameientas de seguridad son muy estricto con los ports...

Pero me pondre en campaña a probarlo, no deberia ser problema en win7

Saludos
:P :P :P :lol: :lol:

Re: Crear DB de MariaDB

Posted: Fri Nov 08, 2019 1:46 pm
by dragancesu
@mol

I don't know for MariaDB, for MySQL is https://www.uniformserver.com/. It's variant WAMP server, I use and start only MySQL. Posssible make zip and unzip at another location. I don't try but be possible delete other programs apache, php, if not need
This is simple and useful for testing

@Ismach

You know mysql/mariadb but think about localhost and windows. MySQL/MariaDB is better, what if install on Linux? if the installation is on linux then forget about the folders and access to the files

Database management program is a better solution and works everywhere