Exporting drupal site from local host causes missing tables - mysql

I have a functional site on my local laptop that I am trying to port to a webhost. Now I was successful in doing this once which must have been a stroke of luck. When an issue forced me to wipe and rebuild, I now find myself unable to migrate the site. Now when I try I get a bunch of errors regarding missing tables.
My process was as follows:
Export mysql table;
FTP website files and sql datatable;
Import sql datatable into new sql database;
Visit the new IP address.
Was I lucky and any way I can fix it? I do not have that much content but I would like to avoid recreating it all.
Please help!

Not sure how helpful I can be without knowing what the specific error messages are.
One thing I can think of is dropping the database and recreating it. Assuming you have command-line access:
mysqladmin drop database_name
mysqladmin create database_name
And then use mysql to import the new dump file. I find this is the safest way as sometimes mysql complains about "duplicate tables" or something similar when you try to restore over the top of an existing database. I can't give any better advice without knowing what the specific errors are.
I suppose you have already done this, but also make sure you server meets the minimum Drupal requirements: https://drupal.org/requirements

Related

Some file lost in MySQL database. How to re-create it in proper way?

The problem is, that one MYI and one MYD file from MySQL database has been accidentally deleted. The only file left intact is FRM one. Only one table from the whole database is damaged that way, all other tables are OK and the database works generally fine, except the table with deleted files, which is obviously inaccessible.
There's a full database dump in pure SQL format available.
The question is, how do I re-create these files and table in safe and proper manner?
My first idea was to extract the full create table command from the dump and run it on live database. It's not so easy, as the whole dump file has over 10GB, so any operations within its content are really pain in . Yes, I know about sed and know how to use it - but I consider it the last option to choose.
Second and current idea is to create copy of this database on independent server, make a dump of the table in question and then use resulting SQL file to create the table again on the production server. I'm not quite experienced with MySQL administration tasks (well, just basic ones), but for me this option seems to be safe and reasonable.
Will the second option work as I expect?
Is it the best option, or are there any more recommendable solutions?
Thank you in advance for your help.
The simplest solution is to copy the table you deleted. There's a chance mysqld still has an open file handle to the data files you deleted. On UNIX/Linux/OS X, a file isn't truly deleted while some process still has an open file handle to it.
So you might be able to do this:
mysql> CREATE TABLE mytable_copy LIKE mytable;
mysql> INSERT INTO mytable_copy SELECT * FROM mytable;
If you've restarted MySQL Server since you deleted the files, this won't work. If the server has closed its file handle to the data file, this won't work. If you're on Windows, I have no idea.
The next simplest solution is to restore your existing 10GB dump file to a temporary instance of MySQL Server, as you said. I'd use MySQL Sandbox but some people would use a virtual machine, or if you're using an AWS environment, launch a spot EC2 instance or a small RDS instance.
Then dump just the table you need:
mysqldump -h tempserver mydatabase mytable > mytable.sql
Then restore it to your real server.
mysql -h realserver mydatabase < mytable.sql
(I'm omitting the user & password options, I prefer to put those in .my.cnf anyway)

Where can I find my mySQL database (using locate doesn't help)?

First ever Stack Overflow post, thanks for your time. Any constructive criticism on how to post better, please just let me know. I have done a search on my query and have found similar posts, but I was unable to use the information within them to resolve my problem.
I have created a mysql database using the terminal window in my Ubuntu system (which I am also new to, having been a lifelong windows user). I used the following code in the terminal window:
$ mysql -u root -p
Then once in mysql, I did the following
CREATE DATABASE securities_master;
USE securities_master;
I created a user and tables in the database using some other code, that doesn't seem relevant here, so I won't bother posting. However, I then decided I would like to take a look at the tables in the database, so I downloaded an SQLite browser. It was at this point that I realized I could not find my database file.
I tried to find the answer on previous stack overflow posts, and tried the suggestions of:
locate sqlite
locate .db
locate .sqlite
locate securities_master
But unfortunately, none of these showed the file I was looking for. The only place I can think of would be what is called the 'root' directory in my computer, but the Ubuntu file manager system won't let me view it because it says I don't have permissions. Is this where it might be?
Could someone shed some light on where I might be able to find this file/database? I know it is definitely there because if I try to CREATE it again, I get the message that it can't because it already exists.
Thanks again.
sqlite and mysql are two different databases. You can't use sqlite on a mysql database. sqlite is a single-file database, in which users just open the file and read and write to it, while mysql is a more traditional relational database system with a server and a client, where the server manages the database (which is generally in a directory of files), while the client just connects to the server.
Where the mysql database is located my depend on your system, but it's usually in /var/lib/mysql. You can look in /etc/mysql/my.cnf for the configuration file, which should have a datadir option that refers to where the actual data for the database is stored.
You can check my.ini file to see where the data folder is located.
Usually there is a folder {mysqlDirectory}/data
MySQL data storage:
Commands.frm
Commands.myd
Commands.myi
The *.frm files contain the table definitions. Your *.myi files are MyISAM index files. Your *.myd files contain the table data.
as mentioned in the answer before mine, mysql and sqlite are two different systems.
You mention you used the cmd line mysql to create the database and then wanted to view the tables. If you're simply trying to see which table are created, in the same command line you used to Create the database you can run show tables;
If you're after a GUI for this, we'd need a bit more context. Is this ubuntu system a remote server, or are you using the desktop version?
You say you're a long time windows user, If you're using windows locally, I personally like SQLWorkbench for accessing my remote mysql servers.
EDIT: I just re-read your post and realised you're using local ubuntu desktop so me mentioning remote was silly, my bad! However, SQLWorkbench does have a ubuntu version at https://dev.mysql.com/downloads/workbench/

Importing a 12gb MySQL database into PHPmyAdmin

SO guys, we had legacy website that has a 12GB MySQL database. We decided to port the legacy website to WordPress and need to import the database into PHPmyAdmin without breaking the database and to implement this in the shortest possible time (although time is not such a critical matter if this can be done painlessly but correctly). So would appreciate if someone can guide me in the right direction and provide detailed instructions.
Thanks guys.
I dont know much but i can recommend to back up you're files befored doing any transfers. If you have a fast internet speed then you guys can try to download the SQL database as a compressed file and dump it into the wordpress new database. The database for mysql should be in your cpanel folder (since all cpanel folders/designs are different it would be best to look up "where to find the msql database on hosting company name's cpanel" and once you find it then you can transfer it whereever is possible)
This is the easiest and most correct way.
mysql -u username -p "dbname" < "path/to/bigdata.sql"
If you have FTP/SSH access, then this is the most probable way.
Upload your .sql via FTP
If you have access to CLI , just run the command above
Normally , this will be fast, but since its 12GB, it might take 30min-1hour depending on server resources.
You can also use other options like this one .
I've already experienced importing 61GB before with just this one-liner.

How can I create a secondary database to run alongside my MediaWiki server?

Firstly, my aim is to create a database to store statistical information about my wiki articles, that is derived using extensions that I have written for my MediaWiki server. Then via another extension on my server, I wish to access this secondary database and use the information to edit the output of the final article page.
I wanted to try and make a separate database to avoid introducing errors to the existing MediaWiki schema. Is this possible? I can't find any information about running an additional mySQL database alongside a MediaWiki installation.
I feel as though the better solution may be to add a table to the existing schema, but I'm not sure how to deal with the existing infrastructure without breaking it. I believe I can just use standard CREATE commands but mySQL is unfortunately not my strong point.
Thanks
Hope i understood your problem. say you have media wiki server or a mysql server running on port 3308 and you want to create another mysql instance.
Follow this step:
bkp my.cnf file
start first instance on port 3308
chnage my.cnf settings & make it run on 3307
start second instance of mysql
If you have good h/w,swap/RAM, you can easily create such 4-5 instances & all will be running good.
You can run a separate database along with the primary MediaWiki database. You just have to open a connection to it specifically using the PHP MySQL API.
Adding a new table to the existing database though is really easy and probably your best bet. You will be able to take advantage of the built-in database load balancing if your site ever gets big. To learn how to create a new table from an extension, check out this page of documentation.

How can I get back my privilege to create a new database in MySQL?

I can not use MySQL. MySQL is on my local computer. Currently I added skip-grant-tables in My.ini so I can use MySQL. But I have no privilege to create a new database. My problem is tough, although I asked related questions on SO, but no answer can resolve my problem. I almost give up. So I lower my expectation. I am developing a website, so I need to create database, tables and operate tables. You don't have to consider security. Is there a simple solution that can give me privilege to create a new database? Maybe by adding some command in my.ini or something? You won't need to completely resolve my problem. Maybe after the development, I will upload the database and tables to another server(The current database server is my personal computer, windows XP) so I can uninstall and reinstall MySQL.
The root of problem is that I lack privileges.
I'm not sure if this will work for you, since you might need to have elevated privileges in the first place, but it's worth a shot.
There should be a database called mysql. Take a look in there, and you'll see a table called users. For each record, there's a heap of columns named Select_priv, Insert_priv, etc. For your user record, change each of these to "Y".
It sounds a bit like your installation went astray.
Maybe uninstall/resinstall is your best option, assuming that you've never been able to connect, so there is no data to consider.
Take your time on the installation, and have a look at MySQL Postinstallation Notes
you have 4 questions open about this specific problem. instead of opening duplicates, you should instead update just one of them with new information.
but the simple solution to your problem is to download the ZIP file of mysql for your mysql version from the mysql website and just copy the data\mysql folder in to your data file, then restart the service. this will give you a root user with a blank password that has full access.