Mysql56 for Windows does not recognize any new database - mysql

As the title says, i have a fresh install of mysql56 server for Windows(currently installed on windows 8.1) and the server does not recognize any of my new databases. I've copied a pack of databases from a old hosting and just put them in the "data" directory of the server.
I've tried to restart mysql(process & service) but nothing changed.
Edit: I've created a new database with a new table but the server does not store the new database in the "data" folder. If the data is not stored in the Mysql/Data directory then where?

There are several ways to go. But (like for virtually all databases), you must do some kind of explicit "export/import", or "migration". You cannot simply copy the raw database files into a directory.
My preference is to use good old "mysqldump":
For example:
mysqldump -u username -ppassword –all-databases > dump.sql
You'd then restore on your new Windows install with a command like this:
mysql -u username -ppassword database_name < dump.sql
Here are more details:
http://dev.mysql.com/doc/refman/5.0/en/copying-databases.html
PS:
This tutorial shows you how to export/import with phpMyAdmin (even easier!):
http://www.techrepublic.com/blog/smb-technologist/import-and-export-databases-using-phpmyadmin/

Related

Copying database backup files from xamp/mysql/data of windows to linux in path /var/lib/mysql

Copying database backup files from xamp/mysql/data of windows to linux in path /var/lib/mysql, but it is creating only empty database in phpmyadmin of linux.
Please some one help me to solve this issue, i have only these files backup with me
The best way is-
Step1: Take backup from windows by mysqldump-
mysqldump -uroot -proot123 -A > backup.sql
Step2: Move this backup to linux, you can use winscp tool for it.
Step3: Now restore this backup to linux machine.
mysql -uroot -proot123 < backup.sql
Modification:
It seems your db engine is myisam and you just coppied file/folder from window to linux, so give permissions as per below-
chown -R mysql.mysql /var/lib/mysql
First create a .my.cnf file containing the mysql root password in your users home folder, on linux.
On windows, there exists a .my.ini or something which serves the same purpose. That way you will not have to reenter your passwords a lot during the next steps, which you are very likely to repeat several times until you get them right, I fear. :)
Since unix/linux and windows have different ways to save files, you might very likely run into errors during a simple copy-restore process, depending on how you copy files.
Your best bet is likely copying the original mysql folders to another windows machine and save them accordingly, such that mysql can find them. (With an installed mysql instance, of course.) I don't know what else you might need, if the databases are not found instantly, since I never had to do this prior and have no test setup here to check this case out.
When the databases are found through the mysql on the WINDOWS server, from the mysql cli prompt there look up which encoding etc the db uses:
SELECT SCHEMA_NAME 'database', default_character_set_name 'charset', DEFAULT_COLLATION_NAME 'collation' FROM information_schema.SCHEMATA;
Then create a new database on the LINUX server with the same name and the same encoding's from MYSQL CLI:
create database <db-name> character set <charset> collate <collation>;
Then on the WINDOWS server in a CMD window, do a mysqldump which should look familiar on windows like on linux:
mysqldump <db-name> > <db-name>.sql
Then copy the dump over to the LINUX server and replay it:
mysql <db-name> < <db-name>.sql
Afterwards you will have to recreate a user (if you know which user and password your web app used to access the database, create a new user with these credentials and grant him full access on your database.
If you do not happen to know the credentials anymore, create an arbitrary user and then change the database credentials in the configfile of your web application.
In case you have problems, check the unix file permissions of the files you copied, such that mysql can access them.
Good luck, mate.

Backup DB from MYSQL command prompt

I recently tried to put my web application and mysql database on the same virtual server. Now I receive a port error. In order to fix the port issue, I want to back up the database and reinstall WAMP. Since I can't get to the phymyadmin, I have to use the mysql command prompt to do a dump.
Would anyone happen to know the EXACT command to put in, if my username is root, I have no password, and the database name is dev? I've tried it multiple ways and I get an error saying that my syntax is wrong.
Thanks in advance.
You can use the following command provided you know the name of the database:
mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
Alternatively I would install the MySQL Workbench which can connect to your local database instance and provides a GUI to run the export: MySQL Workbench.
Unfortunately if you've uninstalled WAMP then MySQL might not be running anymore, and the above commands will not work because the utilities cannot see the database. If this is the case, try installing WAMP to a new directory and manually copying over the MySQL data files:
How to restore MySQL database from WAMP?
mysqldump -u root -p dev > devBackUp.sql
DOS batch file to export the database with date and time in the filename
FOR /f "tokens=1-8 delims=:./ " %%G IN ("%date%_%time%") DO (
SET dt=%%G%%H%%I_%%J_%%K
)
mysqldump -u root -p[root_password] [database_name]> [database_name]_%dt%.sql
pause

get the copy of database from mysql

Let's say I remote from my workbrench to the database which is on server now for some reason I need to have copy of the database on my another computer as a local database. How can I do that?
Export it to a single file (whatever.sql), then import it by running the script on your local computer.
There's a "Data Export" link on the left side if you connect to the remote server using MySQL Workbench. Click on that and go through the export process. Then connect to your local server, click on "Data Import/Restore", and choose the file you just saved.
First export data from database, then import database or specific table import in local server.
$ mysqldump -u [uname] -p[pass] [dbname] > [backupfile.sql]
To dump all MySQL databases on the system, use the --all-databases shortcut:
$ mysqldump -u root -p --all-databases > [backupfile.sql]
Source :How to Copy (Backup) a MySQL Database
In addition to a dump and restore you can try the MySQL Workbench migration module which allows to migrate from MySQL to MySQL (useful for instance to upgrade from a previous version or to copy a schema, as in your case).
MySQL Workbench migration (general description, video tutorial, white paper): http://www.mysql.com/products/workbench/migrate/
The MySQL Workbench migration wizard: http://dev.mysql.com/doc/workbench/en/wb-migration-wizard.html

Combining two installs of mysql

Noobish questions
The StartupParameters.plist points to MySQL 5.5.27-community. When I run Querious, a database management application, and create a db, it adds the db to an older version - MySQL 5.5.18 (specifically to usr/local/mysql-5.5.18-osx10.5-x86_64/data).
Questions: how do I move the dbs in the older version of MySQL to the current one? If I do, and then delete the old MySQL directory, will I be ok or are there other changes which need to be made?
Thanks,
Cole
You should simply dump the old databases using mysqldump or similar. Then import those dumps into the new server. You should then be able to safely uninstall your old server and remove the directories.
This is a simple case of exporting the databases and then importing them to another. In your case, use mysqldump to export the database from the older server and use mysql import to import into the newer one.
It is okay to safely uninstall the older version once the database has been exported.
usr/local/mysql-5.5.18-osx10.5-x86_64/> mysqldump -u username -p database > exported.sql
(location of the newer db)>mysql -u username -p -h localhost database < exported.sql

How to move local MYSQL DB up to remote DB server

I have a local MYSQL DB running under WAMP that I need to move up to my production DB server. New to MySQL and need to know the best way to get this DB moved up.
you can run this on your current server:
mysqldump -u user -p database_name > dump.txt
and then do this on your new server:
mysql -u user -p database_name < dump.txt
Replace "user" with your username and "database_name" with a name of your database. You'll be prompted for a password in both cases
Note that second command will replace old tables in your new database
Open up your database in phpMyAdmin and then select Export from the menu. Scroll down and select the Save as file checkbox and then press Go.
Now open up the database in phpMyAdmin on the production server (Note: you will need to create the database first) and then select Import from the menu. Browser to the file you saved and press Go.
If everything goes well you should now have a mirror image of your database on the production server! :)
Do you have phpmyadmin? (If you're not sure, type "http://localhost/phpmyadmin"). If you do, go to "Export on your local computer, and then upload that file on the "Import" section of the remote server. This is the absolute easiest way, and 90% of hosts have phpmyadmin installed.
If you don't, use the command line method suggested by ZeppLock.