0

It's insane. I have tried all the methods but it still throws the same error.

I have a database, want it to run on MySQL-Server. At the beginning of the Database:

DROP SCHEMA IF EXISTS someDB;
CREATE SCHEMA someDB;
USE someDB;

When I tried SHOW DATABASES LIKE 'someDB'; it confirms the existence of it.

I tried:

  1. chmod for the full path to it /var/lib/mysql/someDB/someDB.sql
  2. Stopping MySQL-Server, Deleting the the someDB folder and starting the Server again.
  3. I removed the entire MySQL-Server and reinstalled it again.

After hours of trying, I really need you help.

EDIT: Answering Y. Collin Comment, when I run sudo ls -la ./someDB, it returns:

total 20
drwxrwxr-x 2 ubuntu ubuntu  4096 Nov 14 16:53 .
drwxrwxrwx 5 mysql  mysql   4096 Nov 14 16:53 ..
-rwxrwxrwx 1 ubuntu ubuntu 12243 Nov 14 16:53 someDB.sql
Mike
  • 551
  • 1
  • 6
  • 18
  • You have `chmod -R` the someDB dir? – Pete Nov 14 '17 at 16:48
  • https://stackoverflow.com/questions/4584458/error-dropping-database-cant-rmdir-test-errno-17#4584523 – Pete Nov 14 '17 at 16:49
  • @Pete I have been following the answers in the link you provided all the day, No luck yet. And Yes I have changed the privilege recursively. – Mike Nov 14 '17 at 16:52
  • Reading between the lines you appear to have dropped your restore file into the directory for the SomeDB schema. That was rather silly. Move it somewhere else. And it shouldn't be owned by mysql, it should be owned by the user you are logged in as. – symcbean Nov 14 '17 at 17:04

2 Answers2

0

What do you see if who run the following command:

ls -la ./someDB/

If there is a file in it like in this example you should delete it first.

Credit to @Beel

Community
  • 1
  • 1
Novy
  • 1,436
  • 1
  • 14
  • 26
0

It turned out that I have a logical mistake.

Inside the someDB.sql file, I am using the USE statement. However, I am trying to run the database by using this command:

mysql -u root -p someDB < someDB.sql

Which is absolutely wrong because the above statement prompt the USE which conflicts with the first line in the sql file (i.e DROP SCHEMA...).

The correct way to do it is:

mysql -u root -p < someDB.sql

because the USE statement is placed in the file already!

Mike
  • 551
  • 1
  • 6
  • 18