3

I am trying to drop the database and create it again, obviously, but it will not work.

It gives me the error:


mysql> source /Users/divinedavis/downloads/tract_schema.sql;

ERROR 1010 (HY000): Error dropping database (can't rmdir './tract', errno: 66)

ERROR 1010 (HY000): Can't creat database 'TRACT'; database exits

Database changed

DROP DATABASE IF EXISTS TRACT;
CREATE DATABASE TRACT;
USE TRACT;

# # is used for comment in MySQL
#DROP TABLE employee; 

CREATE TABLE CUSTOMER (
  cust_num   integer(10),
  cf_name varchar(15), 
  cm_init   varchar (2),
  cl_name varchar(15),
  c_address   varchar (40),
  c_uname varchar(15),
  primary key (cust_num, cf_name, cl_name)  
);

CREATE TABLE INVOICE (
  inum    integer(10) not null, 
  i_date    date default null,
  custf_name   varchar(15),
  cl_name varchar (15) default null,
  tech_uname      varchar(15) default null,
  lp_num    varchar(6) default null,
  primary key (inum)
);

#DROP TABLE department; #CASCADE CONSTRAINTS;
CREATE TABLE PAYMENT (
  p_type        varchar(25) not null,
  i_num      integer(10),
  amount       decimal(5,2), 
  foreign key (i_num) references invoice(inum)
);

#ALTER TABLE employee ADD(
#foreign key (dno) references department(dnumber)

#);

#DROP TABLE dept_locations; #CASCADE CONSTRAINTS;


#DROP TABLE project; #CASCADE CONSTRAINTS;
CREATE TABLE VEHICLE (
  model      varchar(25) not null,
  lp_num    varchar (6) not null,
  vin  varchar(17),
  v_year       integer(4) not null,
  v_trim      varchar(10) not null,
  tire_size    varchar(6),
  make  varchar(15),
  mileage       integer(8) not null,
  color varchar(20),
  cust_name varchar(30),
  primary key (lp_num, vin)
);

#DROP TABLE works_on; #CASCADE CONSTRAINTS;
CREATE TABLE TECHNICIAN (
  wage   decimal(3, 2),
  s_name    varchar (23),
  s_num  integer,
  city   varchar(20),
  state    varchar (20),
  zip  integer,
  reviews   varchar(400),
  ratings   integer (5),
  tf_name  varchar(10),
  tm_init   varchar(2),
  tl_name    integer (4),
  t_uname  varchar(15),
  t_ssn integer(9),
  primary key (t_uname)
);

#DROP TABLE dependent; #CASCADE CONSTRAINTS;
CREATE TABLE CREDENTIALS (
  email           char(9),
  username varchar(15),
  user_password       char,
  ssn integer(9),
  primary key (username)
  );

CREATE TABLE RT_CALENDAR (
  time_of_operation    integer(9),
  date_of_repair date
);

CREATE TABLE WORKS_ON (
  cost           decimal(3,2),
  hours integer(15),
  lp_num            char,
  t_ssn          date
);
Community
  • 1
  • 1
Divine Davis
  • 532
  • 1
  • 6
  • 15

4 Answers4

6

Find the DB directory first using command

mysql -e "select @@datadir"

It will return your database directory e.g.

+-----------------------+
| @@datadir             |
+-----------------------+
| /usr/local/var/mysql/ |
+-----------------------+

Goto that directory and delete the database using command

rm -rf DB_name

You can root user too using command

sudo rm -rf DB_name
Neeraj Kumar
  • 6,045
  • 2
  • 31
  • 23
3

It looks like you may have lost some files, which would explain why mysql says the db exists, but you can't delete it due to file not found errors.

There are entries in the system db for database objects and if some files go away (are deleted or whatever) you can't just DROP [database] if this happens.

Check here for the answer.

Community
  • 1
  • 1
Neil Davis
  • 238
  • 1
  • 5
  • How did he get this `sh-3.2# ls -la data/test total 0 drwxr-xr-x 3 _mysql wheel 102 Apr 15 12:36 . drwxr-xr-x 11 _mysql wheel 374 Apr 15 12:28 .. -rw-r--r-- 1 _mysql wheel 0 Mar 31 10:19 .empty` to pop up? – Divine Davis Apr 26 '16 at 19:40
2

Please take a look at this post:

how to drop database

Seems that there are some not mysql files inside tract directory.

Community
  • 1
  • 1
Adrián
  • 419
  • 2
  • 17
0

For some reason the database folder can't be removed. Possibly there is some file there that is not related to the database.

To manually remove the database go to /usr/local/mysql/data/ and remove the /tract folder from there.

jussius
  • 3,114
  • 15
  • 21