Migrating a Mariadb/wordpress site with only .frm files - mysql

My server crashed. My /home /www and lib/mysql were on a different hard disk so I have all the data. The original server was Debian 9 with Mariadb and an apache webserver. I planned to move to mysql so I have a debian 10 server with mysql. I also have another debian 9 server with Mariadb so that I can use sqldump to move my databases. All my databases moved over fine, except one that was a wordpress database. That directory only has .frm files in it, there are no .MYD or .MYI files. I tried copying them to /var/lib/mysql of the Deb9 server, changed the permissions and ownership. However, mysql dump gives the following error message
mysqldump: Got error: 1932: "Table 'dbname.tablename' doesn't exist in engine" when using LOCK enter code here
I tried copying them as is to the MYSQL server too, the server did not see the tables. In the MariaDB server command line interface it shows the tables. However when I try to view the contents of any table it says
Error 1932 (42S02): Table 'dbname.tablename' doesn't exist in engine
I get the same error when I try repair table.
Any ideas on how I can get this moved?

I have resolved my issue. Instead of copying only the database folder, I copied the entire /var/lib/mysql folder to the mariadb install. Then I did sqldump on each database and moved them to the mysql server. I'm not sure why the copy of the database folder didn't work but I got all my data back.

Related

PHPmyAdmin #1932 - doesn't exist in engine

I installed phpmyadmin on Debian. I copied the database folder from an old server into the current MySQL folder. Then came the error # 1932 - Table doesn't exist in engine. I also copied the ibdata1 but to no avail. What can I do?
Kind regards
Copying the data/files works only if
It is the same database server version till the subversion
You have to copy all files from the data directory.
You can tryto upgrade the database for that consult the manual

MySQL corrupts after every server restart

I Have a bit of an odd problem. I am running MySQL and Drupal site from a windows environment (not by choice but it is just how things have worked out) and most of the time the site is fine however every time the server is restarted (from updates or for maintenance) The MySQL Database will corrupt.
When I log in to MySQL Work bench I notice that the server status is stopped and when I try to start it I get the error:
ERROR Fatal error: Can't open and lock privilege tables: Can't find file: 'user' (errno: 2 - No such file or directory)
and then MySQL Server fails to restart.
The only way around this problem is to delete data folder in the ProgramData/MySQL and then replace it with a backup from a fresh install of MySQL then import a backup of my tables and recreate my users.
My Question is what is causing MySQL to corrupt at every sever restart and what can I do to prevent this happening moving forward?
This occurs when mysql can not find or do not have permissions to user.MYD or user.MYI or user.frm in the data directory. When you start mysql, make sure that these files exist in data directory. You can just copy those files when mysql does not start
This worked for me:
Stick with the 32 bit.
Uninstall and make sure you then DELETE the mysql-data folder and all its subfolders before installing, and prefer to use the 32 bit (sometimes 64 bit versions are the problem).
(Source)

Recover MySQL database from .frm

I had two different MySQL installations, one on Ubuntu and another on Windows 7. I wanted to migrate the database on Windows 7 (source) onto Ubuntu (destination).
Some Googling informed me that I have to copy the "datadir" contents to the other installation. This is where I committed a mistake. I did not back up my Ubuntu datadir. My second mistake was copying the entire datadir from source to destination MySQL including the "mysql" folder and files ibdata1, ib_logfile0 and ib_logfile1.
With this my MySQL on Ubuntu crashed. I deleted the ib* files to get MySQL started. After MySQL started, I tried the "show databases" command. Then it listed all the databases from both the source and destination MySQL's. I am able to also list all the tables in the databases. However, when I try executing a "select" query, I get the following error:-
ERROR 1146 (42S02): Table 'itcc.testcase' doesn't exist
When I inspect the folders of my datadir, I see only the .frm files.
Can someone let me know how I can recover my DB and get it up and running?

Mysql gives me:"Can't open and lock privilege tables: Table 'host' is read only"

I am facing problem restoring the mysql database. My primary database was mysql5.1 and now I am trying to copy it to mysql5.5. The database was backed by using Xtrabackup.
I am using Ubuntu 12.04.3 LTS on this server, mysql version is : 5.5.32-0ubuntu0.12.04.1-log
I have followed all the steps to restore using Xtrabackup, this created database files, which I have copied to a tmp directory.
I have modified my.cnf to point to this tmp directory. I have changed the tmp directory permissions and changed the ownership of the files to mysql user.
drwxr-xr-x 12 mysql mysql 4096 Sep 10 10:04 base
Now when I start the mysql server I get this error "[ERROR] Fatal error: Can't open and lock privilege tables: Table 'host' is read only"
I have given a try as follows:
Even tried installing mysql5.1 to see if that was the issue.
tried 'chcon mysql_db_t' to change the context but it gives me "can't apply partial context to unlabelled file"
I have used --skip-grant to get into database, but using this I can only access innodb tables only, MyIsam tables throw read-only error
After --skip-grant, I have used upgrade_mysql this throws me error that many tables are read-only.
I have removed apparmor too. and restarted too.
I have restored a different database(5.1 to 5.5) previously on Ubuntu 12.04.2 LTS without any issues.
Can some please point me in right direction, I am not sure whats wrong with permissions.
Thanks in advance.
Answering my own question,
The issue is with AppArmor. I am not sure why MySql is unable to access files even after uninstalling AppArmor.
Reinstalled AppArmor and moved the MySql profile under disabled profiles of AppArmor, even then it did not work.
I copied the database files under /var/lib/mysql/ and MySql stopped throwing errors

Dropping MySQL Archive Databases

I have MySQL 5.0 running on a Windows 2003 server. I was trying to drop an archive database when I received this error:
Error dropping database (can't rmdir './database_name/', errno: 17)
There are ARM and ARN files in every directory for every archive database on the server. From what I can tell, these are generated during an optimize.
Is it safe to remove these files manually so that a drop command in mysql will go through normally?
It could mean for example - database directory contains some files that is not belongs to mysql database. For instance .empty file.