Error 1046 3d000 Mysql
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
Error 1046 3d000 No Database Selected
Us Learn more about Stack Overflow the company Business Learn more about hiring developers error 1046 3d000 at line 22 no database selected or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack
Error 1046 3d000 At Line 1 No Database Selected
Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Create procedure ERROR 1046 (3D000): No database no database selected mysql selected up vote -1 down vote favorite I am trying to create a simple procedure which would create a new database. complete code which i am trying to run over mysql is : SET @DB_NAME := "mydb"; SET @DB_CREATE:= "CREATE DATABASE "; DELIMITER // drop procedure if exists create_db // create procedure create_db(name TEXT) BEGIN DECLARE temp TEXT; DECLARE user TEXT; SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE error 1046 (3d000) no database selected grant SCHEMA_NAME = name INTO temp; if temp = name then SIGNAL SQLSTATE '45002' SET MESSAGE_TEXT = 'This database already exist'; else SELECT USER() INTO user; SET @s = CONCAT('CREATE DATABASE ', name); PREPARE stmt_create FROM @s; EXECUTE stmt_create; DEALLOCATE PREPARE stmt_create; SET @s = CONCAT('GRANT ALL PRIVILEGES ON ', name, '.* TO ', user, ' WITH GRANT OPTION'); PREPARE stmt_grant FROM @s; EXECUTE stmt_grant; DEALLOCATE PREPARE stmt_grant; END IF; END // DELIMITER ; call create_db(@DB_NAME); I took the help of how do I use a variable in create database statement for creating this procedure. While running this procedure over mysql i am getting error : ERROR 1046 (3D000): No database selected I have googled it a lot but is unable to fix it. While trying different things i tried to execute the above procedure by first executing: mysql> USE mysql; Using that, error is gone. And mysql> show databases; is displaying all the databases along with the newly created database. Could somebody tell me whether using mysql as default database is correct or not. If somebody has another method please tell it to me. mysql mysql-error-1046 share|improve this question asked Jul 1 '13 at 10:23 user2311046 3418 ad
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
Error 1046 No Database Selected Phpmyadmin
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions no database selected mysql php Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million
No Database Selected Mysql Workbench Import
programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ERROR 1046 (3D000): No database selected while creating user up vote 0 down vote favorite When I create a admin user http://stackoverflow.com/questions/17402181/create-procedure-error-1046-3d000-no-database-selected with: GRANT ALL ON * TO my_name@localhost IDENTIFIED BY 'my_passwd' WITH GRANT OPTION I received the error message "ERROR 1046 (3D000): No database selected". mysql mysql-error-1064 share|improve this question edited Nov 19 '14 at 14:12 Lars 1,186823 asked Nov 19 '14 at 13:56 user2823470 312 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote accepted You should be saying it like below by qualifying it with database name. Check http://stackoverflow.com/questions/27018653/error-1046-3d000-no-database-selected-while-creating-user MySQL Documentation for more information. GRANT ALL ON db_name.* So for your case, GRANT ALL ON db1.* TO my_name@localhost IDENTIFIED BY 'my_passwd' WITH GRANT OPTION; share|improve this answer answered Nov 19 '14 at 13:59 Rahul 43.4k63462 or for all databases use GRANT ALL ON *.* ... –Lars Nov 19 '14 at 14:04 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged mysql mysql-error-1064 or ask your own question. asked 1 year ago viewed 6689 times active 1 year ago Related -2Syntax Error in Create Function2Importing using MySQL WorkBench… error ERROR 1046 (3D000)0Error Updating Database with PHP0You have an error in your SQL syntax while doing a basic SELECT0MySQL Error #1064 from Create Table1MySQL Error: #1046 - No database selected-1Create procedure ERROR 1046 (3D000): No database selected-1SQLSTATE[3D000]:1046 - No database selected0SQL syntax error when adding a user to the database through php0codeigniter 3.1 PDO mysql Error Number: 3D000/1046 No database selected Hot Network Questions A Very Modern Riddle Help! My hom
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 http://stackoverflow.com/questions/10653577/mysql-error-1046-3d000-no-database-selected-on-update-query Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL “ERROR 1046 (3D000): No database selected” on no database update query up vote 5 down vote favorite 1 I have an UPDATE query where I explicitely reference the database, but MySQL still complains with the message: ERROR 1046 (3D000): No database selected. Other queries that are similar of structure, but use an INSERT work fine. Other queries that only perform SELECTs also run fine. To repeat the problem in a test case, try running these queries: no database selected create table test.object1 ( id_object1 int unsigned not null auto_increment, total int, weight int, dt datetime, primary key (id_object1) ) engine=InnoDB; create table test.object2 ( id_object2 int unsigned not null auto_increment, primary key (id_object2) ) engine=InnoDB; create table test.score ( id_object1 int unsigned not null, id_object2 int unsigned not null, dt datetime, score float, primary key (id_object1, id_object2), constraint fk_object1 foreign key (id_object1) references object1 (id_object1), constraint fk_object2 foreign key (id_object2) references object2 (id_object2) ) engine=InnoDB; insert into test.object1 (id_object1, total, weight, dt) values (1, 0, 0, '2012-01-01 00:00:00'); insert into test.object1 (id_object1, total, weight, dt) values (2, 0, 0, '2012-01-02 00:00:00'); insert into test.object2 (id_object2) values (1); insert into test.score (id_object1, id_object2, dt, score) values (1, 1, '2012-01-03 00:00:00', 10); insert into test.score (id_object1, id_object2, dt, score) values (2, 1, '2012-01-04 00:00:00', 8); update test.object1 p join ( select ur.id_object1, sum(ur.score * ur.weight) as total, count(*) as weight from ( select lur.* from ( select s.id_object1, s.id_object2, s.dt, s.score, 1 as weight from test.score as s join test.object1 as o1 using(id_object1) where s.dt > o1.dt order by s.id_object1, s.id_object2, s.dt desc ) as lur group by lur.id_object2, lur.id_object1, date(lur.dt) order by lur.id_object1, lur.id_object2 ) as ur group by ur.id_