Accessing different databases via command line than phpmyadmin - mysql

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.

Related

How to access data from a SQL snapshot

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.

Connecting my MySQL databases to phpMyAdmin

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.

Showing phpMyAdmin databases in MySQL

I have set up a new database with phpMyAdmin, but when I log in to MySQL through terminal (Mac OS X 10.9.5) it doesnt show up the new database i created. it only shows 'information_schema' and 'test'.
Is there a certain directory I should go to in terminal before starting mySQL?
You might be using two different schemas for MySQL server and in phpMyAdmin.
As a check, you can try creating a table from terminal, and see if it gets reflected in phpMyAdmin, create table A (a varchar(), b varchar() ). If the new table doesnot appear from the browser (phpMyAdmin) probably you are logging in from two different schemas.
Also FYI: It doesnot matter from which directory do you login to MySQL.
Hope it helps.. :)
When I log into mySQL using "mysql -u root -p" i can access all the databases.

XAMPP mysql access without password

When I access mysql database on my localhost XAMPP installation I usually type
mysql -u user -p
But today I accidentally mistyped it like this:
mysql -u user-p
And for my surpries got connected without any password prompt. I tried that with many users registered in mysql and it seems they all get opened like this. Is that a bug or vulnerability for XAMPP or is it the normal behaviour for the integrated shell application inside the control panel? And if it is the second, how can I change it because anyone else using my computer can easily access any database and table on my server?
quote : RajaRassani
When you type mysql alone, I bet you'll be able to access the database still. I think the default installation has User=Any, Host=% Password=-- (you can check this in the Users tab of your PhpMyAdmin since you already have this with XAMPP)
Actually it really appears to be user related issue, XAMPP adds too much useless users it seems... Thank you for helping!

Tried to Drop Database from phpMyAdmin but failed. Now I can't do anything with it

I wrote a java application that interacts with my database and there was a problem with it. I had to delete the database since there were too many erroneous changes made by my application. I was careful and backed up my database before I ran the program, so I proceeded to drop the entire database with the intention of reverting back to the original.
I used phpMyAdmin to drop the database in question, but after 20 minutes it seemed like nothing was happening so I forced the browser to close and reloaded PMA. Expectedly, the database I wanted to delete still shows up in the list of databases in PMA, but when I try to access it, the browser goes blank and hangs. I tried to access the database from the terminal (I'm using OS X 10.4.11), and when I type 'use name_of_database', the terminal itself hangs too. I also tried to drop the database once again in the terminal, but that also hangs.
How can I get rid of this database now? I could always reload my database under a different name, but this one will still be here and I really want to get rid of it. Any ideas?
You need to reboot the db server... Btw did this happen while running java code on it? Wondering if you forgot to close the connection or if you didnt have a finally block to close the db connection and your program crashed.
delete the database by logging in to mySQL using SSH if you have not already..
sudo mysql -u yourmysqlusername -p (enter the password
when prompted.)
mysql> SHOW DATABASES; (find your database)
mysql> USE YOURDATABASETODROP; (CHANGE THE DATABASE)
mysql> DROP DATABASE YOURDATABASETODROP; (and you are done.)