Mysql Error No Database Selected 1046
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads #1046 - no database selected import with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack no database selected php Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign
No Database Selected Mysql Workbench Import
up Error 1046 No database Selected, how to resolve? up vote 137 down vote favorite 22 Error SQL query: -- -- Database: `work` -- -- -------------------------------------------------------- -- -- Table structure for table `administrators` -- CREATE TABLE IF NOT EXISTS `administrators` (
Error 1046 (3d000) No Database Selected Grant
`user_id` varchar( 30 ) NOT NULL , `password` varchar( 30 ) NOT NULL ) ENGINE = InnoDB DEFAULT CHARSET = latin1; MySQL said: #1046 - No database selected need some help here. sql mysql mysql-error-1046 share|improve this question edited Oct 23 '10 at 18:21 OMG Ponies 199k37360417 asked Oct 23 '10 at 18:19 steph 692253 5 In case anyone is interested, you can also specify the database name via the CLI command without editing the import file. mysql -u root -p databasename < no database selected mysql command line import.sql –Sam Dufel Nov 24 '14 at 15:36 what happened to me was: create a schema, filled in the name of the database, then it says "fail, no database selected". reopen workbench, i see database that i have just failed to created. Then I choose the database that i have just created, and open a .sql file and run, with both create database and use database statements, it complains "fail no database selected" again. reopen workbench, the tables are all built. MAC system, workbench 6.3.3 –Tiina Jun 9 at 9:12 add a comment| 13 Answers 13 active oldest votes up vote 216 down vote You need to tell MySQL which database to use: USE database_name; before you create a table. In case the database does not exist, you need to create it as: CREATE DATABASE database_name; followed by: USE database_name; share|improve this answer edited Feb 24 '13 at 0:02 Piero 2,991946102 answered Oct 23 '10 at 18:21 codaddict 252k50362443 2 In my case, I had used mysqldump to export a database and was running into this upon import. I just had to edit the exported sql file to add these two commands to the top of it. –bh5k Oct 11 '12 at 17:01 Thanks! This is what I needed. I had a script to create my database and tables but the tables weren't getting created because I needed to insert the USE tablename command. –ckpepper02 Apr 21 '14 at 15:23 add a comme
log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow
#1046 - No Database Selected Wordpress
the company Business Learn more about hiring developers or posting ads with us Database Administrators no database selected mysqli Questions Tags Users Badges Unanswered Ask Question _ Database Administrators Stack Exchange is a question and answer site for database professionals who error code 1046 in mysql workbench wish to improve their database skills and learn from others in the community. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers http://stackoverflow.com/questions/4005409/error-1046-no-database-selected-how-to-resolve are voted up and rise to the top Error 1046 Mariadb: No database selected up vote 3 down vote favorite 1 GRANT ALL ON my-database.* TO my-user@10.0.0.1 IDENTIFIED BY 'password'; ERROR 1046 (3D000): No database selected Ok, I have created a database with a "-" on the name (did the same thing on the user)... then when I try to set the grants on it the database wont work. If I use the http://dba.stackexchange.com/questions/27245/error-1046-mariadb-no-database-selected base the error is different MariaDB [(none)]> use my-base Database changed MariaDB [my-base]> GRANT ALL ON 'my-base'.* TO 'my-user'@'10.0.0.1' IDENTIFIED BY 'password'; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''my-base'.* TO 'my-user'@'10.0.0.1' IDENTIFIED BY 'password'' at line 1 MariaDB [my-base]> mariadb share|improve this question edited Mar 8 at 22:54 RolandoMySQLDBA 108k15139276 asked Oct 19 '12 at 14:27 maniat1k 1702516 1 In regards to the second error if you set your database, if you're not running in ANSI-quote sql_mode, ' doesn't escape a database object. Use the back tick ` –Derek Downey Oct 19 '12 at 15:03 1 Slight correction to myself...ANSI_QUOTES affects the double-quotes for escaping...single-quotation never does :) –Derek Downey Oct 19 '12 at 15:14 add a comment| 1 Answer 1 active oldest votes up vote 8 down vote accepted Try escaping it with backticks? GRANT ALL ON `my-database`.* TO `my-user`@`10.0.0.1` IDENTIFIED BY 'password'; Also, if you already have a user my-user@10.0.0.1, you don't need to provide the IDENTIFIED BY... portion of your grant statement share|improve this answer answered Oct 19 '12 at 14:31 Derek Downey 15.8k74885 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up
"#1046: No database selected" error when trying to import a .sql file in phpMyAdmin. Solution #1: Before importing In phpMyAdmin, click on the Export tab from the home page of phpMyAdmin, http://wisercoder.com/how-to-fix-the-1046-no-database-selected-error-in-phpmyadmin/ without selecting any database. phpMyAdmin will then include instructions to create and select the database when you import it. This solution does not apply to most shared hosts, since they won't allow you to create a http://nicolasbouliane.com/blog/importing-sql-databases-from-wampserver-1046-no-database-selected-fix database from phpMyAdmin. Solution #2: The alternative fix Unlike solution #1, this one also works on shared hosts. Create the new database on your server, then write down the name. Open your .sql file with a no database text editor Insert the following line right before the first CREATE TABLE instruction in your .sql file: USE your_database_name_here; Save your file, then import it in phpMyAdmin. SQL Tagged database, errors, mysql, phpmyadmin, sql ← How to get an Integer from a Java resultset How to properly validate email addresses in Java → 21 comments on “How to fix the "#1046: No database selected" error in phpMyAdmin” carle November 13, 2013 no database selected at 11:34 pm many thanks! save my life! Reply Sam June 3, 2014 at 2:08 pm What i get when i export my database is a notepad file format showing mywebname.sql instead of the normal sql file for upload to liveserver….please help as i dont know what could be wrong. Reply Nicolas Bouliane June 3, 2014 at 3:05 pm Upload that file in the import form Reply Manish Atri November 19, 2013 at 7:43 am Thanks a lot Buddy Reply Juanita Alcachofa December 5, 2013 at 6:32 pm Muy bueno, me sirvió. Reply Ivan January 3, 2014 at 11:07 pm Thank you! Solution #2 worked for me! Reply Pizo January 13, 2014 at 10:41 pm Thank you! Reply Mr January 21, 2014 at 11:54 pm Just wanted to add, since your solution led me to the answer : It's all because there is an existing database of the hosting company and they won't allow you to open one yourself, but rather suit yours into theirs. The solution therefore is to 1.export your database in sql format from phpmyadmin localhost 2.open that file with notepad++ 3.edit the first lines to this CREATE DATABASE IF NOT EXISTS hosting_db01 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; USE hosting_db01; where ‘
Contact Blog Fixing the «#1046: No database selected» error Here is the simple, quick fix to the "#1046: No database selected" error when importing a .sql file from a Wamp installation in phpMyAdmin. Fix: In phpMyAdmin, click the Export tab situated under Home instead of the one when you are viewing the database to export. This will allow you to export entire databases and not only the tables contained in it. This might not work for users of hosting sites such as Hostmonster or Hostgator, since they pick the database names for you. Alternative fix: Create the database on your server and note down the name. Open your .sql file with a text editor. You might want to use something other than Notepad since it doesn't recognize the line breaks. Insert the following line before your first CREATE TABLE command in your .sql file: USE yourdatabasename; Be careful to write in the right database name. Hostmonster users, for example, will have their username in front of their database name. Therefore, the products database is in fact named username_products. Save your .sql file and import it using the import tab in phpMyAdmin. Source Gareth a dit (8 juin. 2010): Thanks, this error was really bugging me! willyzl a dit (28 oct. 2011): Very Good solution. It is what I try looking for days. Thank you for your cool solutions. :DD Austin a dit (1 nov. 2011): you are a godsend, sir. LJ a dit (7 jan. 2012): Hi, I still cant do it. After i followed the steps I get and erro 1044. Could you post a video on how to do it? That would be really helpful. My whole website is ready and this is the final step and I am stuck here. I am not a web developer infact and not sure how to resolve it. Cheers, LJ Dennis Guerra a dit (17 jan. 2012): Thank you so much !!! Was desperate Dennis Shruti a dit (12 fÃ