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.
Related
When I try to log into MySQL via command line, keeps saying "unknown database 'magento2'"
Any ideas why? Tried as my username and root, getting the same message. If I can't log into mysql, how could I create a database to begin with of that name? So confused.
You should separate between your database application and a logical database. MySQL server is your database application / server.
When you're logging on to MySQL, you're choosing which logical database you would like to work with. A logical database is actually a container of objects such as tables, triggers, views, etc.
So when you see the error unknown database X, it's because you installed the MySQL server, but didn't create the logical database.
To see a list of all logical databases in your server, login to MySQL and run the command show databases;
To create your database, run the command create database magento2;
Now when you login to that database, it should be there and you can start creating your tables and query data from them.
I had the same issue and found that the database name was set in a cnf file. Perhaps you have something similar.
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 have a local installation of MariaDB on a Windows XP.
I created an empty database db_y which I wanted to populate with the tables of the database db_x which I exported as a dump-file from a MySQL-instance (with HeidiSQL). When I imported the dump-file db_x.sql into the the MariaDB instance:
c:\ > mysql -u root -h localhost -p db_y < "X:/archive/db_x.sql"
I got the following:
- MariaDB-inst
+db_x
+db_y
db_y remains empty and db_x from the dump-file was added (db_x is the database name of the original database I exported). What I have to do to get the desired database name? I thought I could change the database name in the db_x.sql file but I didn't want to open such a large file. Can I change the import command above in such a way that it change the database name?
I'm also interested in this kind of solution:
CREATE DATABASE y FROM DATABASE x
Is something like this possible?
In the net I find the solution RENAME DATABASE which was not recommended and ALTER DATABASE db_x UPGRADE DATA DIRECTORY NAME
but sincerely, I preferred to create a new database with the new name.
Thanks for any help.
Consider you have two databases: source_db and target_db. If you want to copy the database contents from source_db to target_db you should do as follow in HeidiSQL:
Right click on source_db then select: Export database as SQL.
Now change the value of Output and select Database.
A select box will appear, select target_db and that's all.
There is an easy way to transfer a database from one instance to another with HeidiSQL:
Create the database db_y in instance y
Click on dump icon (or right click). The instance y should be activated.
At "Output" option choose Database
At "Database" option choose db_y
Select on the left the instance x and database x
Export
Try MySQL Workbench. It's made by MySQL and I've found it excellent for backing up a database and restoring it under a different name.
http://dev.mysql.com/downloads/workbench/
HeidiSQL's export dialog recently got a new option called "Max INSERT size". This controls the number of rows in bulk/multiple INSERT commands.
Also, there is a documentation for this export dialog.
One of my db have tables around 10000(temporary use).
But what it has done that opening phpmyadmin become slow and my version is "2.6.0-pl2".
Because of this version I cannot use skip_db option of phpmyadmin.
So I decided to have a new user with permission to all database except one but I don't know how to do that.
So can someone tell me how to write grant to all db with skipping just one db ?
There is no need to create a user for this problem.
use show database command and you will get list of db.
In phpmyadmin version "2.6.0-pl2" , you can use show_db variable and set all tables there are your problem will be solved
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.)