I have been given a SQL database snapshot in a file sqlfile.sql
I want to access these data, but I do not know how to proceed. I am new to SQL.
I have a Macbook pro with MacOSX Sierra (10.12) and I have installed mysql with Homebrew. The version of mysql is 8.0.16
running mysql works, I can access the mysql prompt line.
I would like to be able to access the data, in python if possible, but if it has to be through the mysql command line, it is fine. Once I can access the tables, I know how to query the data, that is not any problem.
I tried with MySQL Workbench as well, but it does not work either.
Can someone point me towards some guide on how to proceed? I have spend hours trying to find some clue, but I did not succeed.
Thanks a lot!!!
Finally I managed to solve the problem. It was not really complicated, but I had problems finding the right combination of commands.
What I did was, in the command line enter into the mysql prompt. Once here:
mysql> create database mydatabase
Once done, go outside the mysql prompt and in the normal command line execute:
mysql -uroot -p mydatabase < db_snapshot_file.sql
This populates the database called mydatabase. Once done, from Python I could access it. But first, since I had some problem with the authentication, I had to use this answer to solve it.
To access from Python, I used this information which gave me some indications on how to start.
Related
I am running Mac OS 10.10.2. I have recently been educating myself about php and SQL in order to create an online database application for my employer. However, I have been unable to load up my MySQL databases in phpMyAdmin. I have tried following some advice from this forum, but no answers seem to solve my issue.
I installed MySQLWorkbench (Ver. 6.2.4.12437) as well as XAMPP (Ver. 5.6.3-0), and was using phpMyAdmin to have a play around and better understand what I was getting myself into. I then found one of those follow-the-bouncing-ball type teaching websites which advised me to download and install the MySQL community server (Currently running Ver. 5.6.23)
As instructed, I was learning SQL commands through Terminal and built up some databases/tables this way. I decided I wanted to jump into phpMyAdmin where I felt it'd be easier to continue my work. At first XAMPP was unable to turn on the servers which I overcame by uninstalling and reinstalling. Then I was getting a #2002 error when trying to access phpMyAdmin. I tinkered with config files and put in details relating to my localhost MySQL server (Or at least I assume as much).
I was able to get back into phpMyAdmin finally, but my databases made through terminal are not there.
phpMyAdmin shows: cdcol (the example database), information_schema, mysql, performance_schema, phpmyadmin, and test.
If I open terminal and punch in 'mysql' then 'SHOW DATABASES;' it only lists: information_schema.
If I open terminal and punch in 'mysql' with username 'root' and my password, then 'SHOW DATABASES;' it lists: information_schema, mysql, performance_schema, my tutorial/learning database, and my business database. I dropped the test database from here. THESE are what I want to bring up in phpMyAdmin.
I can only guess that I haven't got it configured properly to access this last mysql server, but I can't determine where I am going wrong. If anyone can shed some light on this, that'd be greatly appreciated.
It appears as if you have two MySQL instances; one from the XAMPP and also the MySQL Community Server that you installed yourself.
The "M" of XAMPP is for MySQL, so yes usually it runs its own MySQL server instance. That's sort of the point of the packaged kit, so you don't have to worry about having any of your own applications installed. In theory it should be no problem to stop the XAMPP MySQL instance and instead use your other one, but may require tweaking some configuration files and is probably not supported. If you can make it work, I don't see a reason why it would be a problem, though.
My suggestion is to either use the complete XAMPP stack or roll your own installation rather than mix and match.
I need a quick and easy way to import MS Excel databases and query them with PL/SQL for a class assignment. So far I've tried downloading MySQL Workbench and SQL Developer based on my class recommendations. MySQL Workbench looks simpler so I'm trying to learn to use that.
I'm completely lost on how to get started. Is it required for me to connect to a SQL database server before importing data? If so, how do I create one? I'm working off of my laptop and again, this is just for class so I don't need anything fancy.
I apologize for the very basic questions, as I have just started with learning databases. I researched for 2+ hours trying to figure out what to do, as my class resources aren't helpful and I must not be googling correctly as I can't find answers. If it's helpful at all, I've been successfully working with MS Access for SQL queries, so I'm comfortable with the environment. Thanks in advance.
xampp is provides a control panel for start/stop the mysql server, you can download xampp from here. After installing xampp set the enviroment variable in your system for recognizing mysql commnad in your command prompt.
you can access mysql command line in your command prompt like this,
mysql -u root
I 've re-installed mysql, uninstalled MAMP.
So currently I should only have one version of mysql.
I've done the following:
Installed phpmyadmin
Created a database
I try to import data to it, but the file is too big so I do it via the command line. But there I dont see my newly created database, furthermore I see less databases.
If I do show databases; on the command it shows:
information_schema
test
It doesnt show my newly created Database and it doesn`t show other databases that were pre-installed, these are the databases that I see on phpmyadmin:
information_schema
mysql
performance_schema
test
myBBDD->the one I just created and I was looking for to import data via command-line
It seems I have two versions of mysql, but if I stop mysql via command line, I then can't access phpmyadmin so I guess it's the same one, but for some reason I can't access the same databases.
If you could throw me a bone on this? Im completely lost.
To install mysql and phpmyadmin I've followed this tutorial
[EDIT]
I tried to delete test and it did dissapear from the command-line too, so it is the same version of MySql, so it must be a permission issue... still investigating
Thanks.
Sounds like you have MAMP's version of MySQL and a standalone MySQL. See this answer:
Access MAMP's MySQL from Terminal
Just had the same issue, in my case it turned out to be that I wasn't logging in as the correct user.
In the command line, instead of running just mysql, try running mysql -u root -p (replace "root" with whatever user you used in phpMyAdmin to set the databases up). You should then be able to type in the password. Check show databases; again.
Just noticed that user Grasshopper in a previous answers' comments was suggesting exactly this, hopefully this will help someone anyway by spelling it out.
I recently upgraded to Mountain Lion from Snow Leopard, and in doing so threw my entire local development environment into disarray. I solved the majority of my issues by finally installing MAMP Pro (I was previously using the "native" methods provided by Apple). The problem I have now is I still can't access my old mysql databases. I can view the "new" databases via phpmyadmin in MAMP, but I have old projects that I'd like to work on.
My old databases still exist in /usr/local/mysql/data, but they don't appear in phpmyadmin or even if I query via Terminal (after logging in to mysql & using the show databases; command). I'm sure the answer involves just a few simple commands, but I'm mainly a front-end guy, and I can't for the life of me find the solution on the internets.
Thanks.
UPDATE:
Just a reference for anyone else who might have this issue (or something similar). In order to do the dump, I ended up having to turn off MAMP's instance of MySQL, and starting up the old version (through System Preferences). Otherwise I was getting 1049 errors ("unknown database"), I suppose since it was looking at the new databases instead? Really out of my element here, if you can't tell...
Either way, now it looks like it actually doesn't matter if the MAMP version is active or not. Maybe I just needed to restart all instances of MySQL? Seriously, no clue, but all is good now...
Try this in terminal to dump old databases (replacing [text]):
/usr/local/mysql/bin/mysqldump -u root -p[pass] [db] > [filename].sql
Once you have the sql file you can import it back in with PHPMyAdmin within MAMP.
I need to make an installer for a MySQL 5.1 Database, but I'm totally a noob when it comes to installers.
I've been looking at NSIS and learned a little but I don't really know how to use it to just to execute a script.
Anyone out there has experience installing database schemas in multiple computers?
thanks
So I didn't have time to figure it out but I made a batch file that executes a mysql script
http://dev.mysql.com/doc/refman/5.0/en/batch-mode.html
so batch file had this
cmd /c mysql -h host -u user - p < scirpt_file_in_same_folder_as_batch.sql
The only problem was that mysql had to be set as enviroment variable path by default.
To cancel script execution you just dont write a password when promped
hope this helps someone out there.