Database missing error - mysql

In my xampp,i could not start the MYSQL section.So XAMP re installed.Before reinstallation i keep database backup from the path C:\xampp\mysql\data.
After reinstallation paste datafolder content into this path.Then I tried to accessing phpmyadmin,then database and table names are listed there.But there is no content into each table.While clicking the database table, it shows an error table does not exist.Please give any solution for my this issue.Thanks in advance

Well, dumping DBs is pretty easy. I assume you are on localhost and your user name is root.
Make sure your MySQL server is up and running.
Run Command line and for dumping ALL your DBs, type:
mysqldump -u root -p --all-databases > dump.sql
Hit Enter. The system will ask you for a MySQL password, type it and hit enter. If there's no password set for your server, just hit Enter. Your dump file will be saved in the current directory.
To restore the dump (e.g. after you reinstalled MySQL), run Command line again and make sure you are in the same directory where your dump.sql is. Type:
mysql -u root -p < dump.sql
It will ask you for a password. You know what to do. Depending on how many data you have it can take some prolonged time. Hope it will help!
P.S. Dumping/restoring single DB is a little bit different, let me know if you need it and I will update this post.

Related

How to manually upload database

I was working on a site offline. Now, due to some reason, it's not working. I've tried almost everything. To save time, I have setup a fresh mysql and wordpress site.
Now, I have theme files and database folder files like: dp.opt and wp_addonlibrary_addons.frm. How can I properly upload them?
I tried to manually do it, but some error came saying these tables already exist.
Please advice.
I assume your questions is about importing the DB again in MySQL?
Are you still able to export the database from your not working site? Than you could do this (source):
mysqldump --add-drop-table -u user -p > dumpfile.sql
And import it again on your new site with this command:
mysql -u user -p < dumpfile.sql
You won't get the error about already existing tables.
If you can't reach the old database anymore or not able to export, drop the current database first on your new site (make sure you made a backup).
DROP DATABASE databasename
CREATE DATABASE databasename
You can also drop all tables instead of dropping the database. You can use this script: https://www.cyberciti.biz/faq/how-do-i-empty-mysql-database/
Or my preferred method is using PHPMyAdmin to drop all tables.
Then re-import with:
mysql -u user -p < dumpfile.sql

Uploading Big MySql Files in Phpmyadmin

Im trying to upload a 3.8gb sql dump into phpmyadmin, in wamp. I set the max_file sizes among other things to 5gb and even restarted the server multiple times. The php_info(); also gives me 5gb as the file size.
I would like to break the file into smaller chunks so that I can upload it bit by bit,if the entire thing isnt possible, and have looked for such tools. Used one though http://www.rusiczki.net/2007/01/24/sql-dump-file-splitter/ but it gives me an error at 2gb.
Could anyone suggest anything that i could do to get my dump into mysql?
Thanks a lot
Traverse to your mysql bin directory (e.g. below)
D:\wamp\bin\mysql\mysql15.1.36\bin>
Then you can import any large database from your dump file giving the following command (e.g. below)
mysql -u username -ppassword database_name < dump.sql
You should really skip phpmyadmin and do it through the command line. The correct command is:
$ mysql -u username -p -h localhost DATA-BASE-NAME < data.sql
If you are still unsure about that one (although try it, you'll be surprised how easy it is) you can have a go at mysql workbench.

Back up MYSQL data after loosing access to PHPMYADMIN interface

I just want to know how to back up data From MYSQL database and Still be able to use that data
again on reinstalling MYSQL ?
NOTE-- i got into this problem after changing my ROOT password . I posted a question regarding fixing this .But unfortunately don't got the solution .So i decided the last step will be to BACK UP my data !
Here is a LINK to that
post
Can't connect after changing MySQL root password in WAMP
P.S----I HAVE NO ACCESS TO PHPMYADMIN
go to your wamp installation drive, and then go to wamp folder
traverse it if the drive is C: and installation folder is WAMP
C:\wamp\mysql\data\
you will see the folder as the name of your database here
copy it to other place and paste it after reinstall phpmyadmin in the same position
Okay, assuming that you know the new/old/current root passwords run the following
mysqldump -u root --all-databases -p
This should ask you the password and dump sql onto the stdout.
To save it to backup.sql,
mysqldump -u root --all-databases -p > backup.sql

backing up/copying mysql database

I have a DB which is a live one, what I'm looking to do, is to make a copy.
I have access to MySQl via SSH and phpMyAdmin.
Is there a command where I can copy/backup the DB, in a single command/action, without using export/import?
Thanks
mysqldump -u USERNAME -pPASSWORD databaseName > SAVETOFILE.sql
see this http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html for various options available.
you can do via PHPMyAdmin as well see here http://php.about.com/od/learnmysql/ss/mysql_backup_3.htm
Login to phpMyAdmin
Click on your database name
Click on the tab labeled EXPORT
Select all tables you want to backup (usually all)
Default settings usually work, just make sure SQL is checked
Check the SAVE FILE AS box
Hit GO
If you want to create DB that is a copy of above sqldump you need to do run the following command
mysql -u USERNAME -pPASSWORD < SAVEDFILE.sql
But, I feel you are looking for something like replication. In that case you need to set-up master-slave configuration where data gets replicated on slave. See this guide for replication
http://dev.mysql.com/doc/refman/5.0/en/replication-howto.html
Ok, so I found a command that would take a dump of one database and then insert it into another DB using a single command:
mysqldump -u username -ppassword live_db | mysql -u username -ppassword backup_db

Problem in importing database in MySQL

I have a .sql file with some database backups inside. Now I want to restore them back to MySQL. How can I this using command line of MySqL please? I found this:
mysql -u username -p -h localhost database_name < dumpfile.sql
but I don't know what username should be, what database_name should be and how I could browse to a .sql file in another folder.
You need to replace username with your database username and it will prompt you for a password. If the dump file has the "create database [name];" and "use [name];" instructions then you dont need to specify the database_name attribute.
To pull the .sql from another folder you just need to specify the path (/home/user/Downloads/file.sql, for example).
You could also try downloading mysql administrator from the mysql website.
Check this link too
http://www.techiecorner.com/31/how-to-restore-mysql-database-from-sql-dump-file/
Redirecting a .sql file into the MySQL CLI works because that's the format that mysqldump produces. And people usually call mysqldump to dump a whole database, so they get one file afterwards.
The username and password are dependant on what's been setup on the database instance you want to reload the data in to. On a clean, empty install, the MySQL root user will work (and probably won't have a password). On an established install, you should find an appropriate user. The user you use will need substantial permissions as it needs to create and write to tables.
The .sql file may have CREATE database and USE database statements near the top. If this is present, then make sure that database does not exist before you pipe the file in. If not, you will need to find out what name is expected by whatever program will be using the database.
As for piping another file in in a different directory, this is simple shell notation. The < filename notation fully supports paths so you can do < some/other/path/filename.sql or < ~/sql/filename.sql, for example. (Note that I've assumed you're using a Unix shell.)
You can use cmd
type cmd run as adminstration (C:\windows\system32>)
give path of mysql of bin folder (C:\windows\system32>
cd `C:\xampp\mysql\bin)
C:\xampp\mysql\bin>mysql -u username -p -h localhost database_name
type-> use database_name
type-> source F:/example.sql