Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phpMyAdmin "No database selected" MySQL

I downloaded a MySQL backup file and promptly imported into MAMP's phpMyAdmin. I got this return:

Error
SQL query: 

--
-- Database: `mysql`
--
-- --------------------------------------------------------
--
-- Table structure for table `columns_priv`
--
CREATE TABLE IF NOT EXISTS  `columns_priv` (

 `Host` CHAR( 60 ) COLLATE utf8_bin NOT NULL DEFAULT  '', 
 `Db` CHAR( 64 ) COLLATE utf8_bin NOT NULL DEFAULT  '',
 `User` CHAR( 16 ) COLLATE utf8_bin NOT NULL DEFAULT  '',
 `Table_name` CHAR( 64 ) COLLATE utf8_bin NOT NULL DEFAULT  '',
 `Column_name` CHAR( 64 ) COLLATE utf8_bin NOT NULL DEFAULT  '',
 `Timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
 `Column_priv` SET(  'Select',  'Insert',  'Update',  'References' ) CHARACTER SET utf8          NOT NULL DEFAULT  '',
PRIMARY KEY (  `Host` ,  `Db` ,  `User` ,  `Table_name` ,  `Column_name` )
) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_bin COMMENT =  'Column      privileges';

MySQL said: 

#1046 - No database selected 

I did not alter the .sql file at all. Any hints on how i can get this puppy going locally?

Thanks!

like image 917
NateHunt Avatar asked Dec 19 '12 10:12

NateHunt


People also ask

How do I fix no database selected in MySQL?

If the error arises due to not selecting a database, you can easily overcome it by replacing [database_name] with the correct database name in your server. When creating a table statement from the MySQL workbench, you need to select the database to run before executing the statement.

Why database is not showing in phpMyAdmin?

If you have multiple xampp applications setup then it's possible it might be on a different phpmyadmin instance. If you are indeed only using the one xampp instance then technically it should show in the phpmyadmin area, unless it's configured in such a way that it's not showing…

How do I fix #1046 No database selected?

Error 1046 occurs when we miss to connect our table with a database. In this case, we don't have any database and that's why at first we will create a new database and then will instruct to use that database for the created table.

How do I find MySQL database in phpMyAdmin?

Navigate to your control panel and click the phpMyAdmin icon. Locate the database you want to search by clicking on the database in the left column. Once inside the database, a list of tables will be displayed.


2 Answers

In phpMyAdmin make a new database or select a existed database. Then import the SQL file.

like image 73
Jordi Kroon Avatar answered Oct 05 '22 04:10

Jordi Kroon


Just create a database with some name first of all. Click on that database and then import your table. The problem here is when you import any table it looks for which database you are using. So, either do as I said above or add this just above CREATE TABLE IF NOT EXISTS columns_priv (

USE your_db_name;//here your_db_name is the database you just created. 

That's it.

like image 44
Anwar Avatar answered Oct 05 '22 04:10

Anwar