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:
chmod
for the full path to it /var/lib/mysql/someDB/someDB.sql
MySQL-Server
, Deleting the the someDB
folder and starting the Server again.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
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!