I am just starting to use Electron and I have a question about databases. Due to the kind of App I am developing I need a relational DB.
The idea is the user will open the App, if there is connection it would store the data both locally and remotely. If the App is offline it will store the data locally and whenever is online again it will send that data to the remote server. Basically it will be thee same database (local and remote) but it can work offline if necessary.
I am lost on which database will be better for this. As I said I am using MySQL right now and I know you can use MySQL with nodejs so I might give it a try. Also, I am used to use MySQL within a backend language such as PHP, how would you do it in Electron?
Thanks for your time guys!
I have an in-memory database embedded in my application and I want other applications to be able access it via ODBC.
After searching for an hour, I think I have 2 options.
Write my own ODBC Driver which knows how to talk my application via the network.
Implement MySQL or Postgres wire protocol in my application so that the client application can use MySQL/Postgres drivers.
According to Creating a custom ODBC driver writing my own driver is a huge task and should not be taken lightly.
So here are my questions.
If I have to implement the wire protocol, am I correct in assuming that I can just create a thread which talks to database and communicates with the clients over the network? That sounds fairly simple to me.
Do you know of any reasons why I should choose one of MySQL/Postgres/Some other wire protocol over the others? My queries will be basic SELECT statements.
Is there any simpler way to access my in-memory sqlite DB via ODBC?
I'm new to the world of databases and would appreciate any pointers for further reading.
You should create your own ODBC driver. Maybe you don't need to implement all ODBC functionality, and a subset will do.
Trying to emulate a different database with its quirks and idiosyncrasies will probably be more difficult.
I'm trying to solve the problem described by CWE-798, specifically how to allow my application to authenticate to a database securely. I would like to set a mysql password within mysqld and push that information out to a PHP application server. This entails communicating the new password from mysqld to PHP before a PHP instance attempts to connect to the mysqld.
(I did read through the suggested approaches on mitre.org and have some knowledge of privileged access management - however NONE of the recommendations actually solve the problem).
Unless this is initiated within the mysqld e.g. using its event scheduler, then I need to maintain some sort of script outside MySQL which will need credentials to connect - thus defeating the objective.
My problem is that I don't know how to get MySQL to initiate a client connection to the application to inject the new password; it does not appear to provide a standard function for invoking a URL nor for executing a program.
Is my only option to implement a UDF?
The vulnerability you're describing seems to primarily relate to applications that are in the hands of users that can freely inspect what they've been given, such as might be the case in a desktop application or a mobile app. If you have credentials in there you must take great pains to encrypt them, and then prevent that encryption from being cracked by protecting your key, but seeing as how all of this has to happen on the user's hardware you're fighting a battle you may never win.
This is how the DVD encryption was cracked, the private key for decrypting DVD data was stored in a desktop application and eventually uncovered.
Server-side code has different concerns. Here you want to avoid hard-coding credentials into your application not because you're concerned about hostile users per-se, though that can be an issue, but because you do not ever want your credentials to end up in a version control system.
One way to ensure this never happens is to have the credentials stored in a file external to your application, like a config file that the application can reference. Most frameworks have some kind of configuration file (.yml, .ini, .xml) that define how they connect to the database. This file should be stored on the server and only on the server, not on developer workstations, not in your version control, and especially not somewhere shared.
You can go down the road of using something like Zookeeper to manage your configuration files but the investment of time required makes this a futile exercise unless you're managing hundreds of servers.
So the short answer here is: Don't put your credentials in your code, or store it with your code. Put it in a config file that's kept on the server and the server alone.
I'm looking for share database from two server into one server, for sample that there is one mysql database server relate to shopping database from hostgator.com and there is two shopping websites server from other hosting company NOT from hostgator company, my question is that is this possible to login in into other company sever use that database from other two from shopping site server from other company!
If possible how, do we can use that! what do we called this! is there is website that i can learn more!
many thanks.
Use:
$con = new mysqli ("SERVER_IP","db_user","db_pass","db");
Instead of
$con = new mysqli ("localhost",...);
You need to create a user for the database with host % permissions and you need to allow remote access to the database, see here:
enable remote access
Hope this was what you are looking for
Any application can directly use any database if the application can "see" that database. What this means includes, but is not limited to:
Both the application and the database and currently running
The hosts running the application and the database can reach each other over a network
The database service is reachable by the application over the network
Necessary ports aren't blocked
Necessary permissions are enabled
etc.
As long as there doesn't exist a condition by which one instance can't "see" the other (such as a firewall preventing host and/or port access) then it makes no difference what hosts the application and database are on. It's just a change to the connection string.
However, if there does exist such a condition (such as a blocked port, which would be very common in this scenario) and the database isn't "visible" to the application, then you have two options:
Correct the condition (for example, open the port)
Create an intermediary API
In many cases, particularly where you don't own the network infrastructure being used, the first option may not be possible. (Even if you do own the network infrastructure, it may not be advisable for security reasons. Internet-accessible databases are generally frowned upon unless you really understand the security of that database.)
So in the event that you need to create an API, this would simply be an additional application which can see the database (possibly running on the same host, or within the same firewall) and which exposes functionality that is visible (such as a web service instead of direct database access). It can be very simple, exposing just get/save (CRUD) functionality to the database. Or it can be more intelligent, exposing business operations over the data which external clients can use. It's up to you.
A database-server serves all requests, weather coming from local-host or remote client
and to listen any request, a database server must run on a port to listen requests on that port.
As far as i know, Microsoft access don't run on any port,
and it is not possible to request Microsoft access on remote machine using
DriverManager.getConnection("URL", "user", "password");
but possible if your data-source is MySql, Oracle, etc... using,
DriverManager.getConnection("jdbc:mysql://ipAddress:portNo./schemaName", "user", "password");
(if i am wrong, please correct me).
Please u guys here help me with the concept, weather Microsoft access is a
a mere file for storing data (because it don't runs on any port),
or a database server
(because for Microsoft-access Type-1 driver is available ,
it means it must be a data-source because drivers are only available for data sources).
Access does not provide networked connectivity beyond a file share. There is no "Access" port.
Access is not a database to begin with.
It is an application development environment that ships with a default database engine, Jet (or ACE in A2007, which is just an updated version of Jet), and that uses Jet MDBs or ACE ACCDBs for storing its application objects.
Your question is not about Access. It is about the Jet database engine.
Jet is not a server database. There is no process running on the server through which all communication with the Jet data store is managed.
Instead, Jet is a file-based database system. Each user runs Jet locally in memory, and opens the database file in shared mode. Locking of the database file is managed via the LDB file.
ODBC does not provide server functionality to Jet data. It is simply another user of a file.
Microsoft Access databases can be used over ODBC or using a shared file system, so from that standpoint they can be considered multiuser databases.
This not really a database server from the standpoint that, there is not one location that serves queries up to clients. Unless you are using ODBC, each "client" has it's own copy of the database engine.
Access is not designed for many users, and does not have many of the properties that you normally think of when talking about database servers. Including scalability and robustness.
MS Access is a file-based database system but technically speaking, so are many other database systems. SQL Server, for example, will store it's data in a single file and can behave in a way that's very similar to Access. Then again, SQL Server has much more additional features.
But is Access a database server? Well, that depends on your definition of what a server should do. It is possible to create an Access database and give it some server-like functionality by writing some code to "serve" your data to some client application. Been there, done that. And actually, Access has been popular in the past for several cheap-hosted websites as database to e.g. run a forum or guestbook on.
To make things more interesting, Access databases can be accessed through COM. And COM objects can be created on a remote system. So theoretically, through ADO you can already access an Access database on another machine.
Access is also reasonably able to handle multiple users and offers some basic security, if need be.
MS Access is also more than just a database file format, although most people tend to forget this. MS Access is part of MS Office and as such it provides much more functionality than just a file-based database system. (Then again, even Paradox is more than just a file-based database if you buy the complete product from Corel instead of just using the database files plus drivers.)
Btw, the term "server" can be confusing. You don't need to run something on a port to make it a server. Basically, a database server is just some program that provides database services to other programs and computers. With Access, you can technically do both, so yes: Access is a database server. (Albeit a very primitive one.)
In determining whether something is a server or not, the issue of whether it has ports is a red herring. Ports are simply one means of interprocess communication. As others have already noted, other servers use named pipes or shared memory to communicate with clients.
The architectural feature that really makes a server is process isolation. This is true whether you are talking about web servers, database servers, or display servers like X Windows. In each case you have some important resource that you want to guard very carefully. Therefore you don't let anything but a few select processes touch it. If another process wants access to that resource, they don't get to work with it directly. They have to send the server process a message, "Hey server please perform operation X on Y and send me the results". The channel used for sending the message is relatively unimportant, the key point is that some independent process is charged with managing the resource. Contrast this with Access (or as somebody pointed out more correctly the Jet database engine). If your application uses an Access database, then your process open file handles on the database, performs the record locking, and does the index lookups. This is all conveniently hidden by many layers of library calls, and it probably involves many switches to kernel space, but in the end it is still your process that is getting all the CPU cycles and doing all the work. This is true even if you are accessing the Access database via ODBC, which is really just another layer of library calls.
AFAIK, MS Access is a database and you can connect to it through ODBC etc, but it is not a database server in the way SQLServer, MySQL, Postgres or Oracle are database servers.
Access is a file that can be attached to via the JET engine or many others. But it is a file. This means that if too many people attempt to connect to it there have been stories of it becoming corrupt and the whole db lost! It is not anywhere near as powerful as the other database engines you mentioned.
It does not run on a port. It's just a file.
If you put the file on a windows file share, then protocol is SMB, the port is 445. The machine with the file is called a File Server, so in a sense, it is a server app, but MS-Access isn't the server, the SMB bits are. What SMB doesn't do that a real sql server would do is manage the concurrent access.