I exported a database from a production server and I'm trying to import it into my local test environment. When I try to import it gives me the error below on multiple tables.
ERROR 1146 (42S02): Table 'abc123' doesn't exist
I have verified that the tables do exist in the production database and the sql file has the create table statement:
CREATE TABLE `wp_posts` (
...
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
On the Production Database, the Collation is set to latin1_swedish_ci and each table Collation is set to `utf8mb4_unicode_ci' which I have replicated in the local database.
Production Database server: Server version: 5.7.34
Local Database server: Server version: 5.7.24
I have read through a lot of posts on SO and can't find a solution to this.
EDIT:
I was able to fix this problem by increasing the packet size in mysql.ini
I was able to fix this problem by increasing max_allowed_packet to 64MB in the mysql.ini.
Related
I am using ubuntu and after restarting the mysql server it gives an error - Table 'db.table' doesn't exist in engine
Table exists, frm / ibd is in place and has owner mysql
Before that I did Optimize table
ERROR 1932 (42S02): Table 'db.table' doesn't exist in engine
I just installed phpmyadmin 4.0.8. Am trying to use it to access 4.1.20 database running on Linux. When I attempt to log into the database server using phpmyadmin, I get this error:
SELECT * FROM information_schema.CHARACTER_SETS
MySQL said:
Documentation
1146 - Table 'information_schema.CHARACTER_SETS' doesn't exist
Tried disabling information_schema in config:
$cfg['Servers'][$i]['DisableIS'] = true;
$cfg['Servers'][$i]['ShowDatabasesCommand'] = 'SHOW DATABASES';
But, get same error. Is there some workaround for this so that I can still use phpmyadmin to manage this database? Any suggestions?
Thanks!
-ron
show databases;
If this command doesnt show information_schema it means your mysql version is old.
I see yours is MySQL version 4,for INFORMATION_SCHEMA you need 5.
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.
I run a daily backup mysqldump backup of the production database (mysql version 5.1.66):
mysqldump --user=username --password=secret -C -e --create-options --hex-blob --net_buffer_length=5000 databasename > file
I also do a daily restore of that database on my development machine (mysql version 5.6.12)
mysql --user=username --password=secret databasename < file
I get the error:
ERROR 1813 (HY000) at line 25: Tablespace for table 'databasename.tablename' exists. Please DISCARD the tablespace before IMPORT.
My reading indicates this is because the mysql innodb database requires the command:
ALTER TABLE tbl_name DISCARD TABLESPACE;
to be run before the table is dropped -- it seems that dropping the table isn't sufficient to get rid of its indexes.
(my development server uses the innodb_file_per_table option)
I don't want to use 'replace' option because i could potentially have data in my development database that was deleted on the production database.
btw after the error the tables are not readable, but restarting mysqld fixes it.
So the question is, is there any mysql dump option that will help fix this issue, or is there another way to import the data that will prevent the error?
thanks in advance for reading.
Sounds like you have a tablename.ibd but no tablename.frm.
To check:
cd to your mysql data directory then the database name.cd /var/lib/mysql/database_name
Search for the table name that is giving the error.
ls tablename.*
You should see two files:
tablename.ibd
tablename.frm
But I'm guessing you don't and only see tablename.ibd
To fix you have a few options:
Add the follow to mysqldump, which will cause the database to be dropped, cleaning up data directory, before restore.--add-drop-database
Copy the tablename.frm from prod over to dev and then issue a delete table statement.
Also:
No need to use net_buffer_length=5000 when you're dumping to a file on localhost.
Other backup solutions - Percona Xtrabackup
I found the easiest way to skip this problem was to manually edit phpmyadmin database dump and edit/change the table that had problems to something else than INNODB. I changed the problem table to ENGINE=MyISAM and voila. Import worked.
CREATE TABLE IF NOT EXISTS `home3_acymailing_tag` (
`tagid` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(250) NOT NULL,
`userid` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`tagid`),
KEY `useridindex` (`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
I also encountered that problem while dropping a schema and creating it again. I overcome this issue by going C:\ProgramData\MySQL\MySQL Server 5.6\data\my_database_name and deleting the tables which remained from the previous database creation. You can also delete the entire database, if you wish.
if you are using XAMPP then first ("stop") MySQL
Then go to C:\xampp\mysql\data\dnb
where in my case dnb is my database name folder.
so then open it and delete .ibd file hence you can only delete it when you already stop MYsql .
then go to phpmyadmin
1 click on phpmyadmin .
2 click on databases that appear below (server.127.0.0.1 in your case my be change)
3 then check your database which you want to drop,and click on drop.
4 then you can create database with same name and import your database successfully .here you can see how you drop database from phpmyadmin
I have a recently set up VPS with cPanel.
I've made a user and created a database, and now I would like to import a database onto it.
However, when I try I get the error message
#1044 - Access denied for user 'user'#'localhost' to database 'database'
I suspect that this can be fixed with WHM, but I do not feel like trial and error just yet.
How would I go about fixing this?
When you import a database using phpMyAdmin, normally you do so by importing a text file with a .sql extension. Here is a section of code that may be in a .sql database backup. In your example, the database you are trying to import is named database.
-- phpMyAdmin SQL Dump
-- version 2.11.9.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Apr 02, 2010 at 08:01 AM
-- Server version: 5.0.81
-- PHP Version: 5.2.6
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE DATABASE database;
-- --------------------------------------------------------
--
-- Table structure for table `table`
--
CREATE TABLE IF NOT EXISTS `table` (
`column1` text NOT NULL,
`column2` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
When using phpMyAdmin to attempt to import such a file, you will receive an error message similar to:
Error
SQL query:
CREATE DATABASE database;
MySQL said: Documentation
#1044 - Access denied for user 'user'#'localhost' to database 'database'
In this scenario, the cPanel username is user. Because of cPanel's database naming conventions, all database names must begin with the cPanel username followed by _. Using this format you can only creat a database named user_database.
The reason this import failed is because of the following line in the .sql file...
CREATE DATABASE database;
Again, you cannot create a database named database, however you can create a database named user_database.
If you change the line that says: CREATE DATABASE so that it creates: user_database instead of database it will again fail with the following message:
Error
SQL query:
CREATE DATABASE user_database;
MySQL said: Documentation
#1044 - Access denied for user 'user'#'localhost' to database 'user_database'
When using cPanel, databases must be created within the cPanel itself.
Here are the steps to correct thi sissue:
Create the user_database database within cPanel
Comment out the CREATE DATABASE command in my .sql file
To do this, simply change:
CREATE DATABASE database;
to
-- CREATE DATABASE database;
You are simply adding dash-dash-space to the front of the line to comment it out so that it will not be executed.
Log into phpMyAdmin, access the user_database database, and then import as normal.
Before dumping your database, grant full access to your new database user created in Cpanel by the same password of that user:
grant all on database_name.* to database_user#localhost identified by 'password';
Then you need to modify your .sql file (can use notepad++), comment out the part where says create and use the new database:
-- Database: dbname
--
-- CREATE DATABASE IF NOT EXISTS dbname DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
-- USE dbname;
then you should be able to import it to your Cpanel.
To make it official...
The file you're attempting to import probably has something that you don't have permissions for. I would check permissions, then the file you're importing.