Cannot use database tables after reinstalling wampserver - mysql

I have just reinstalled WAMPSERVER without backing-up the data folder of MYSQL under WAMPSERVER, with the understanding that uninstalling and re-installing WAMPSERVER would leave the data directory of MYSQL intact as it is. This was a re-installation of the same WAMPSERVER version.
So now I login to MYSQL, can see all databases and tables from previous WAMPSERVER using SHOW DATABASES, and SHOW TABLES IN myDb. But trying SHOW COLUMNS IN myTable or further attempt to access the data in these tables fails, giving the error:
ERROR 1146 (42S02): Table 'myDb.myTable' doesn't exist
and the logfile:
2013-10-08 14:42:23 1072 [Warning] InnoDB: Cannot open table myDB/myTable from the internal data dictionary of InnoDB though the .frm file for the table exists.

try an CREATE if not exists query, see what output this gives.

Related

connecting MySQL database to copied and pasted data directory

I copied a database directory from the datadir (/var/lib/mysql/) of a MySQL instance running on a server to my local machine. Is it possible to put this database directory into my local MySQL datadir and access that database?
What I have done so far is copy the database directory like above, I log in to the MySQL and can see the database, I switch to it and can list all the tables. But when ever I try to query a table I get something like:
select * from users limit 1;
ERROR 1146 (42S02): Table 'users' doesn't exist
Also from mysqldump:
mysqldump: Got error: 1146: Table 'very_first_table' doesn't exist when using LOCK TABLES
Is it possible to do what I am trying to do here?
So I got it to work, bare in mind that my end goal was to get a database dump from the database. The mysql folder was extracted from a older virtual machine snapshot which could not be run at the moment, so I couldn't just log in to it and do a normal dump. Here is what I did:
1) I installed mysql on a fresh vm on my local machine
2) I shut down mysql with service mysql stop
3) I removed the existing /var/lib/mysql folder from the fresh install
4) I replaced it with the /var/lib/mysql folder that was removed from the old snapshot
5) I ran chown -R mysql:mysql /var/lib/mysql
6) I restarted mysql with service mysql start
7) Then I checked if I could log in and query the tables, I could!
So I was able to run the dump after that.

Erreur #1146 Table 'xxxxxxx' dosen't exist'

I get database from server linux debian /mnt/var/lib/mysql/directorybase the files frm and copy the directorybase in C:\wamp\bin\mysql\mysql5.6.17\data
my local machine wampserver but I get this error in phpmyadmin when I access my table in phpmyadmin then error message
#1146 - Table 'avvvc' doesn't exist.
File log I have this:
[Warning] InnoDB: Cannot open table avis_prod/sib_model_forms from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.

Restoring database after reinstallation of MySQL

I had to reinstall MySQL some time ago, before doing it I had moved /var/lib/mysql/mydatabase to another directory to be able to restore it after installation of MySQL.
After I installed MySQL I moved back this directory. When I go to mysql console and use
SHOW DATABASES;
it returns list of databases and 'mydatabase' is among the list.
When I switch to using 'mydatabase' and use
SHOW TABLES;
it shows the list of tables, but when I do any SELECT command I get this error:
ERROR 1146 (42S02): Table 'mydatabase.mytable1' doesn't exist
From the very beginning - was it enough to backup only /var/lib/mysql/< DATABASE_NAME > to restore database data or have I missed something? If yes then what I could try to fix this issue with 'table doesn't exist'?
MySQL version is 5.7, OS is Ubuntu 16.04
MySQL 5.7 default storage Engine is InnoDB. This stores the data in ibdata,ib_logfile0, and ib_logfile1. If you haven't backed up these files then you cannot restore the data.
It is suggestible that instead of moving your database files we should use mysqldump utility.
It is better to use innodb-file-per-table which can store InnoDB tables in a .ibd file per tables.

Table exist in the mysql folder. mysql error files doesn't exist

My system was crashed. I try to import my database from .frm files.
I copied those files to my new mysql server location . '/var/lib/mysql'.
I gave the change the priviledge. I had one database.
I just compied the following files to my database foloder name 'my_school'.
ibdata1
ib_logfile0
ib_logfile1
I copied the whole folder to mysql folder location in ubuntu 14.04, /var/lib/mysql
I gave the privileges to this folder using this command.
chown mysql:mysql /var/lib/mysql/my_school -R
Then, I try to access the database. I can access the database. I can see the tables. but, it give error when I try to see the table structure or data.
the error it show this is.
ERROR 1146 (42S02): Table doesn't exist but both table files (frm, ibd) exists on the file system
I used these solutions, these solution doesn't work.
MySQL > Table doesn't exist. But it does (or it should)
MySQL > Table doesn't exist. But it does (or it should)
Please, help.
Is .frm file contain both data and structure of the data ?
what is purpose of ibdata1 file?
what is purpose of ibd_logfile0 and ibd_logfile1 ?

Tried to create DB with Django by mistake

So I read somewhere that Django doesn't create the DB in production on MySQL. It only created the tables and you have to create the DB in MySQL before you can do syncdb. However, I made the mistake of doing syncdb when the database with the name in my.cnf didn't exist. And now I'm locked out of mysql. I can't log into it using mysql -u root -p. It gives me error: ERROR 1049 (42000): Unknown database
Figured it out. Just comment out the part specific to the database in which Django tried to create tables (in the file my.cnf). Then you should be able to log into MySQL.