I'm working on a project atm, and I need to import data that is stored in a MS ACCESS database to mySql. For mySql I'm using phpMyAdmin on a Ubuntu machine, I have another Windows Machine where I can access the Access DB from, In MS Access 2003 I can't find an option to convert the data to mySql? Can this be done?
Take a look at Access to MySQL. Makes it easy to convert an Access database to MySQL.
It's always possible to do a quick and dirty export from Access to any ODBC database by selecting a table in Access and simply choosing EXPORT from the File menu. One of the export options (in the dropdown at the bottom) is ODBC, and if you have a DSN set up for your other database, you can export directly. Obviously, the data types won't necessarily be perfect for the target database, but it won't misconvert any data -- you just may need to tighten up the data types after the export.
I think it's astonishing that Access can do this, to be honest, but it works.
step by step guide to running Access frontend application with MySQL database on webserver (you dont need to IMPORT the tables, you can use your msaccess application WITH them on the webserver) and EXPORTING MsAccess tables to MySQL (once you start down that path, you want it to be a two-way road, believe me):
If you are running MsAccess, i suppose that you are using windows
Install MySQL ODBC 5.1 Driver (connector) http://dev.mysql.com/downloads/connector/odbc/
Open CONTROL PANEL on win machine
ADMINISTRATIVE TOOLS (if Vista or Seven, search ODBC)
SET UP DATA SOURCES ODBC
SYSTEM DSN
ADD
depending on your server, you might have some difficulty finding the server name or IP, look for SSH Database connection (or something like that). as an example, read NetSol's FAQ: http://www.networksolutions.com/support/how-to-back-up-the-mysql-database-using-ssh/
if you want to BATCH EXPORT / DUMP to MySQL from MsAccess, you can create a FORM in access, put a button on it, and in VBA create this sub for the OnClick() event:
Dim sTblNm As String
Dim sTypExprt As String
Dim sCnxnStr As String, vStTime As Variant
Dim db As Database, tbldef As DAO.TableDef
On Error GoTo ExportTbls_Error
sTypExprt = "ODBC Database"
sCnxnStr = "ODBC;DSN=DSNname;UID=userOnServer;PWD=pwdOnServer"
vStTime = Timer
Application.Echo False, "Visual Basic code is executing."
Set db = CurrentDb()
For Each tbldef In db.TableDefs
Debug.Print tbldef.Name
sTblNm = tbldef.Name
DoCmd.TransferDatabase acExport, sTypExprt, sCnxnStr, acTable, sTblNm, sTblNm
Next tbldef
MsgBox "Done!"
On Error GoTo 0
SmoothExit_ExportTbls:
Set db = Nothing
Application.Echo True
Exit Sub
ExportTbls_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ExportTblsODST"
Resume SmoothExit_ExportTbls
sometimes, while running non-english windows you might get error 2507. change "ODBC Database" for "ODBC" (works with French).
IMPORTING: in MsAccess:
1. FILES
2. EXTERNAL DATA SOURCE
3. LINK TABLES
an MsAccess frontend doesnt really care what database engine it is using, so safe practice is to have 2 separate MDB's: queries, forms, macros, etc AND raw data. that way, you can seamlessly switch from using local database to remote server. and your core application file doesnt contain data proper.
Related
I am developing an application in excel in which data can be updated remotely ie, data is read from an online database and loaded into excel upon start up. I know this can be done by reading from html tables on a website however, was wondering if it could be done through phpmyadmin directly.
Yes, it can (surprisingly).
Though I strongly recommend exposing your MySQL database as an ODBC data source instead.
In Excel, create a new spreadsheet and go to the Data tab, and under "External Data" choose "From web query", then follow the instructions and enter thr address of your phpMyAdmin installation, login, get to the data, then select the table. Excel will remember your login details and cookies for future data refreshes, though it can be a bit wonky as the feature hasn't really been updated in over a decade (source: I asked some members of the Excel dev team a few weeks ago myself)
phpmyadmin is just a GUI for PHP functions that connect to a MySQL database. You would have to communicate directly with the database or via a PHP script that does so for you.
You can do that. Its just simple.
Take an example that you have a table with following fields.
1) ID 2) Name 3) Email
Now create a csv with 3 columns in it with the data, for eg
1,Rushit,Rushitdawda#gmail.com
2,Test,test#gmail.com
Now go to phpmyadmin and create a table and then go to import & upload the sheet and you are done..
I have a huge Database on the server and i need that DB in SQLite so that i can use it in my application in android as well as in ios app.
I got one solution for this when i go to phpmyadmin and select my db on server i exported the Tables one by one into CSV file and then imported those in my SQLite Browser one by one to get all the tables (And Then corrected column names and type manually by editing every table columns).
This way i made it as a .sqlite DB to be used in the app.
But i want to know more on these points below :
Is their some kind of a backend application that most developers use to convert their DB into SQLite DB. (If yes then what kind of stuff do they use)
Is their any PHP script that can do this stuff. (If yes then what script is used and how ?).
Is their any other simple way to deal with this problem of getting SQLite DB from the server. (If yes then what are the possible ways to do this ?).
Can any one get me some idea about this ?
Reference: Copy Database Sructure of Mysql Database
Here's my problem... I have a site that I use PPC to drive traffic to. I track the visitors' keyword, PPC source, ad versions, etc. Currently I store this data in a MySQL DB (InnoDB) named visits. However, when this PPC campaign is running full throttle it generates a lot of data. Every so often my site crashes because this DB fills up and stops responding. (And because I forget to manually do a copy and empty...)
So now I want to create a PHP or Ruby script that runs once a week/month to put the gathered data into an archive DB and empty the DB used for data collection. I assume the fastest way is to rename the existing DB visits to something with a date stamp in the name like visits_010113_020113 for the month of Jan 2013. Then copy create a new visits with only the structure. The primary key is 32 char hash generated by PHP's md5 function so duplicate keys due to auto-increment is not an issue.
(I chose a DB to store the data in because I'm familiar with DBs and I wanted to be able to parse data for custom reporting. I am open to suggestions of a different architecture but I don't want to be spending the next 3 weeks coding up new classes and such for a new architecture right now.)
I ran a Google search on copying the structure of a DB to a new DB (the first result is the one I referenced above and most of the rest of the first page were very similar). However, the solutions all use mysqldump through the CLI. I want to do everything via PHP or Ruby. I could use an SSH class I have for PHP to execute the CLI but that seems like a hack.
I was hoping there was a simple SQL statement I could pass to do the renaming and copying. My preferred solution would be entirely in PHP. I use PHP 5.3.10-1ubuntu3.6 with Suhosin-Patch, mysql 5.5.29-0ubuntu0.12.04.2, and Ubuntu 12.04 server. I also use PHP's PDO object to interface with MySQL.
Thanks
So this would require you to have a list of the tables that need to be copied, but I like
CREATE TABLE cur_db.tbl_name LIKE old_db.tbl_name
So your script could rename the DB, create the new db, then run this in a loop over your table names.
I'm creating locally a big database using MySQL and PHPmyAdmin. I'm constantly adding a lot of info to the database. I have right now more than 10MB of data and I want to export the database to the server but I have a 10MB file size limit in the Import section of PHPmyAdmin of my web host.
So, first question is how I can split the data or something like that to be able to import?
BUT, because I'm constantly adding new data locally, I also need to export the new data to the web host database.
So second question is: How to update the database if the new data added is in between all the 'old/already uploaded' data?
Don't use phpMyAdmin to import large files. You'll be way better off using the mysql CLI to import a dump of your DB. Importing is very easy, transfer the SQL file to the server and afterwards execute the following on the server (you can launch this command from a PHP script using shell_exec or system if needed) mysql --user=user --password=password database < database_dump.sql. Of course the database has to exist, and the user you provide should have the necessary privilege(s) to update the database.
As for syncing changes : that can be very difficult, and depends on a lot of factors. Are you the only party providing new information or are others adding new records as well? Are you going modify the table structure over time as well?
If you're the only one adding data, and the table structure doesn't vary then you could use a boolean flag or a timestamp to determine the records that need to be transferred. Based on that field you could create partial dumps with phpMyAdmin (by writing a SQL command and clicking Export at the bottom, making sure you only export the data) and import these as described above.
BTW You could also look into setting up a master-slave scenario with MySQL, where your data is transferred automatically to the other server (just another option, which might be better depending on your specific needs). For more information, refer to the Replication chapter in the MySQL manual.
What I would do, in 3 steps:
Step 1:
Export your db structure, without content. This is easy to manage on the exporting page of phpmyadmin. After that, I'd instert that into the new db.
Step 2:
Add a new BOOL column in your local db in every table. The function of this is, to store if a data is new, or even not. Because of this set the default to true
Step 3:
Create a php script witch connects to both databases. The script needs to get the data from your local database, and put it into the new one.
I would do this with following mysql methods http://dev.mysql.com/doc/refman/5.0/en/show-tables.html, http://dev.mysql.com/doc/refman/5.0/en/describe.html, select, update and insert
then you have to run your script everytime you want to sync your local pc with the server.
I have a windows program which generates PGP forms which will be filled in later.
Those PHP forms will populate a database. It looks very much like MySql, but I can't be certain, so let's call it ODBC.
And, yes, it does have to be a windows program.
There will also be PHP forms which query the database - examine which tables and fields it contains and then generates forms which can be used to search the database (e.g, it finds a table with fields "employee_name", etc and generates a form which lets you search based on employee name.
Let's call that design time and run time.
At design time, some manager or IT guy or similar gets to define the nature of the database and at runtime 1) a worker fills in the form daily and 2) management can extract reports.
Here's my question: given that the database is defined at "design time" (and populated at run time), where and how is best to do so?
1 I could use an ODBC interface from the windows program, but I am having difficulty finding something good to work with Delphi. Things like ADO and firebird tend to expect you to already have a database and allow you to manipulate it, but I can find no code example of how to create a database and some tables, so ...
2 I could used DOS commands from Delphi in my windows program. I just tried and got a response to MySql --version, but am not sure if MySql etc are more interactive. That is, can I use a script file or a very long stacked command with semicolons and returns separating? e.g 'CREATE DATABASE db; CREATE TABLE t1;'
3) Since the best way to work with databases seems to be PHP, perhaps my windows program could spit out a PHP page which would, when run in a browser, create the database.
I have tried to make this as uncomplicated as I can, but please feel free to ask questions. It may be that there are several valid ways, but there is probably one 'better' solution in terms of ease of implementation or maintenance.
Better scratch option 3. What if the user later wants to come back and have the windows program change the input form? It needs to update the database too.
Creating a database is usually a database administrator task. Unless it is a local database, maybe an embedded one, the user would need to know where and how create the database on the remote server, and she can have no clue about it. Where to store the database files? Which disks are available? And there could be many more parameters to set (memoery buffers size, etc.), users to be created and so on. And also you need very elevate privileges to be able to create a database, not something you give to average users or applications.
Thereby usually you ask the database administrator to create your database/schema, he will give you the credentials you need to connect, and then your application (or its setup) will create and initialize the needed objects (tables, etc.). Creating table (and other object) is usually as simple as running "CREATE TABLE...." statements. Just remember SQL takes one command only, if you need to run several commands you have to send them one after another yourself, although there are Delphi components which are able to split a script in commands and run one after another.