How do I use a mysql db after creation with terminal? - mysql

I have created a mysql database and a table on terminal. The data is stored in /usr/local/mysql but my db is a folder and a table has .ibd extension.
How do I get a normal .db extension with a table inside?

The .db file extension is normally used by SQLite, which is a different database product than MySQL.
SQLite is an embedded database. You can write client programs that use the SQLite library to read and write .db files. But it's limited to read and write files that are located on the same computer where your client program runs.
MySQL is a client/server database. You shouldn't read and write the data file directly. The only program that does that is mysqld, the MySQL Server daemon.
You can write applications that use the MySQL client library to open a socket or TCP/IP connection to convey commands to the MySQL Server. This allows the MySQL Server to be on a different computer than where your client program runs. Your client program can request data remotely, over a network. Likewise, other client programs on yet other computers can also make network connections to the MySQL Server's computer. It supports many remote connections at the same time.
You should probably learn more about using MySQL. The manual has a tutorial section.

Related

Mysql, changing file location to remote in local network

I have 4 computers and 1 server in my local network, there is Xampp(with Mysql) installed on each computer, what I'd like to do, is to cofigure it the way that all mysql data from all computers be saved on the server, so each computer will be talking to the server
you could install mysql on the server, and point all php development to access database on the server. instead of local host.
this should be as easy as changing the database configuration part of your php
just be sure to create user for remote access in the mysql server.
if each computer client have already data in their local database, then dump all databases and recreate on the server.

mysql replication without direct connection

I am trying to replicate a remote mysql database to my internal mysql server.
The problem is that I do not have a direct connection available between both mysql servers.
Internally, there is a custom server application (which I've developped my self). This server application allows incoming connections on 1 port only (with ssl encryption). Once the connection is made, custom written commands can be executed over that connection (like sending specific backup files, remote browsing, etc... just client/server stuff).
Now I need to add mysql replication, but there is no direct connection possible. I was thinking to write something like a PORTFORWARD command in my server app which would transfer the replication data to the mysql server interally, something like this:
remote mysql server replication process->remote client application->internal server application-> internal mysql server.
That would probably work, but I think that's gonna be a fragile solution, all connect/disconnect events will need to be forwarded in all circumstances.
Any better ideas for this?
Thanks,
Vincent
Replication in the sense do you want the Remote server database data's to your Internal server?
if So you could follow Backup and Restore MySQL Database Using mysqldump
Or If want your client server application to access the remote server database follow this Can't remotely connect through SQL Server Management Studio

inspect mySQL database

I have a mySQL database on my Windows PC. I'm pretty sure I've found the relevant files, namely the following:
formula.frm
formula.ibd
db.opt
What is the natural way to inspect, edit, and generally play with the contents of these files?
You do not view the binary database files directly. MySQL is a service that you connect to with a client and then perform SQL commands. You will need a client (such as MySQL Workbench) to work with the server.
MySQL Workbench is the GUI tool that allows you to connect to a MySQL database and perform actions on it including querying and creating/modifying the various parts of the database.
MySQL Workbench intro: http://dev.mysql.com/doc/workbench/en/wb-intro.html
Getting started with MySQL: http://dev.mysql.com/doc/refman/5.6/en/tutorial.html
There is also the command-line utility that is included when you install the server. It will be in the BIN folder of the MySQL install directory.
Command-line client info: http://dev.mysql.com/doc/refman/5.1/en/mysql.html
Use a tool like Mysql Workbench to connect to the DB. You do nothing directly to the files. You connect to the service and use the DB.
William, it sounds like your question is "how do I take mysql binary files and turn them into something usable on my machine?". If that's the case, you'll want to first install MySQL on your machine if you haven't already. Then you might have a look here for how to recreate a database from a .ibd file.

Gaining access to mysql given physical access to the machine

I own a machine running third party software. I input data into this software and it stores that data into its own mysql database. I'd like query the mysql database directly, but I don't know the credentials that the application is using.
I have read and write access for all files in the machine, including the files in the mysql data directory. Theoretically, I should be able to read the data directly from these files (.ibd and .frm files). But practically, I don't know where to start. I'm thinking that these data files are somewhat readable since encrypting them would destroy their index-ability.
Is this feasible? Or would I have to reverse engineer the data file format in order to read it?
Or even better - is there some config file that I can change which would implicitly trust all local connections similar to postgres?
You could read the mysql files directly, but even if they're now encrypted, the columns names might be weird and you could have to spend some time reading them.
Another point could be looking for config files from that software, that could have the login/password (very very low probability, but who knows?)
And the best would be:
make a backup of the mysql files
in another mysql instalation / computer (to not break your software), follow the reset mysql password guide
Try accessing it via the command line on the local machine:
shell> mysql db_name
(from MySQL documentation)
From here, you can create yourself an account if you need to connect from other client software.
Or have you already tried that?
If you have root access to the machine that MySQL is running on, then you can reset the MySQL root password by following the procedure at: http://www.cyberciti.biz/tips/recover-mysql-root-password.html. Once you've reset the root password, you can then login to MySQL as the root MySQL user, and access any of the databases, and query them. The only caveat to keep in mind is that changing the MySQL root password could potentially prevent your application from accessing the MySQL database, but that would be surprising as the application should be designed to connect to the database using a MySQL user account (with limited privileges) other than the root MySQL user.

Connecting to MySQL with Tcl

I had a question about where a MySql database has to sit for a Tcl application to read it. Currently, I have a Tcl application that reads off of a sqlite database. For the application to find the database, the Sqlite Db must be located in the same folder as the Tcl application. I am planning on upgrading the Sqlite Database to MySql.
Will the MySql database also have to sit in the same folder as the Tcl application? I noticed that the connection string for MySql in Tcl doesn't require a directory path, similar to connecting to Sqlite.
Thank you,
DFM
SQLite databases are actually only a single file (so, your application needs to know where that file is) ; on the other hand, MySQL is a daemon to which your application will access via a network connection (and you're application will need to know the address of the server to which it should connect, plus DB name and login/password).
So, there is no such notion as "in the same directory" for a MySQL DB : you can actually put your MySQL server on a different computer/server, it'll still work the same : you will access it via a network connection.