Crear DB de MariaDB

HMG en Español

Moderator: Rathinagiri

jorge.posadas
Posts: 89
Joined: Mon May 19, 2014 7:43 pm
DBs Used: DBF, SQLite, MS-SQL, ACCESS, MariaDB (en proceso)
Location: Tizayuca, Hgo. México
Been thanked: 6 times
Contact:

Crear DB de MariaDB

Post by jorge.posadas » Wed Nov 06, 2019 6:52 pm

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
Cordialmente

Jorge Posadas Ch
Tizayuca, Hgo.
M é x i c o .
Movil +52 55 1427 2013
SKYPE: jorge.posadasch
Email: jorge.posadas@gmail.com

User avatar
dragancesu
Posts: 713
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia
Has thanked: 24 times
Been thanked: 149 times

Post by dragancesu » Wed Nov 06, 2019 10:52 pm

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

User avatar
dragancesu
Posts: 713
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia
Has thanked: 24 times
Been thanked: 149 times

Post by dragancesu » Wed Nov 06, 2019 10:57 pm

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 )

User avatar
Ismach
Posts: 110
Joined: Wed Nov 28, 2012 5:55 pm
DBs Used: DBF, mySQL, Mariadb, postgreSQL, Oracle, Db2, Interbase, Firebird, and SQLite
Location: Buenos Aires - Argentina
Been thanked: 7 times

Post by Ismach » Thu Nov 07, 2019 2:22 am

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

User avatar
dragancesu
Posts: 713
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia
Has thanked: 24 times
Been thanked: 149 times

Post by dragancesu » Thu Nov 07, 2019 8:17 am

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

User avatar
Ismach
Posts: 110
Joined: Wed Nov 28, 2012 5:55 pm
DBs Used: DBF, mySQL, Mariadb, postgreSQL, Oracle, Db2, Interbase, Firebird, and SQLite
Location: Buenos Aires - Argentina
Been thanked: 7 times

Post by Ismach » Thu Nov 07, 2019 3:23 pm

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
Last edited by Ismach on Thu Nov 07, 2019 9:01 pm, edited 1 time in total.

User avatar
Ismach
Posts: 110
Joined: Wed Nov 28, 2012 5:55 pm
DBs Used: DBF, mySQL, Mariadb, postgreSQL, Oracle, Db2, Interbase, Firebird, and SQLite
Location: Buenos Aires - Argentina
Been thanked: 7 times

Post by Ismach » Thu Nov 07, 2019 8:59 pm

;) ;) ;) ;) ;)
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:

User avatar
mol
Posts: 3247
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 228 times
Been thanked: 132 times
Contact:

Post by mol » Fri Nov 08, 2019 9:25 am

Is it possible to create portable installation of MariaDB?

User avatar
Ismach
Posts: 110
Joined: Wed Nov 28, 2012 5:55 pm
DBs Used: DBF, mySQL, Mariadb, postgreSQL, Oracle, Db2, Interbase, Firebird, and SQLite
Location: Buenos Aires - Argentina
Been thanked: 7 times

Post by Ismach » Fri Nov 08, 2019 1:01 pm

: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:

User avatar
dragancesu
Posts: 713
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia
Has thanked: 24 times
Been thanked: 149 times

Post by dragancesu » Fri Nov 08, 2019 1:46 pm

@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

Post Reply