Different login credentials show different tables mysql - mysql

When i just write "mysql" in bash - it show only 2 databases.
When i write mysql -u root -p and then enter password - 2 more db occur.
Why is it happening?
+ bonus question: i backed up "data" directory from previous mysql installation, which crashed.
How to restore tables from .ibd and .frm files?
mac os 10.9

Why is it happening?
As documented under SHOW DATABASES Syntax:
You see only those databases for which you have some kind of privilege, unless you have the global SHOW DATABASES privilege.
Presumably the account under which you connect to MySQL when no explicit credentials are provided (i.e. as set in the relevant option file) only has permission to see two of your databases.
How to restore tables from .ibd and .frm files?
See Copying Tablespaces to Another Server (Transportable Tablespaces). If the files are in the server's data directory, you can use IMPORT TABLESPACE:
ALTER TABLE tablename IMPORT TABLESPACE

Related

transfer all the databases in phpmyadmin

is there a more efficient method to transfer all the databases from phpmyadmin,rather than to create database copies and manually import them on other machines.
Earlier I tried to copy the entire folder and replace the older config.inc.php but I am unable to see all the databases
there are a couple of options which usually depends on your needs/db size/tables engine and so on:
mysqldump + rsync dump + restore (if you do not have a good connection between hosts)
mysqldump | mysql -h H -u -p
If you can't stand with big downtime you can setup replication between two hosts using innodbbackup utility
If you use MyISAM tables you can shutdown MySQL you copy related files to destination datadir. This option will not work for InnoDB tables.

MySql backup and restoration

Trying to find out how people do a full backup/restore procedure: The user defined database schema and data can be easily backed up via mysqldump, but what about the master tables and data? i.e. if the server goes completely bananas, how can I rebuild the database, i.e. including all the settings in Mysql? is it just a matter of dumping/importing the information_schema and mysql databases + restore my.cnf ? (innodb or MyISAM, not ISAM)
--
edit: Thanks!
You don't back up information_schema, but otherwise, yes, keep a copy of your my.cnf and a dump of the mysql db tables and log settings. To do this do:
mysqldump -u$user -p$pass --all-databases > db_backup.sql
If you're going to restore to the 100% same version of MySQL, you could also backup by shutting down your server and doing a full copy of the contents of /var/lib/mysql (or wherever your data files are) along with your my.cnf file. Then just drop the copy back in place when you want to go live and turn on your server.

How to restore data from MySQL .frm?

I have all data in MySQL's .frm files. How can I restore the data? I do not want to restore all of them, just some records and tables so I need to make dumps out of them.
From what I can see, there are only .frm files, no .myd files. There is, however, ibdata1 file. How am I supposed to restore?
I got it working.
1) I created an empty database named after what the real database was on the server in my local installation.
2) I killed "mysqld"
3) I copied the three ib* files to my local MySQL data directory (on Windows it was a hidden folder in root drive). Make sure you copied to InnoDB data file directory, depending on your my.cnf InnoDB and MyISAM data may be stored in different folders. I also copied the .frm files.
4) I ran "C:\Program Files (x86)\MySQL\MySQL Server 5.1\bin\mysqld" --defaults-file="C:\Program Files (x86)\MySQL\MySQL Server 5.1\my.ini" --innodb-force-recovery=6
5) I ran mysql -uroot -pmypass to confirm use mydb; select * from mytable; returned results.
6) I used mysqldump mydb mytable --compact > file.sql
That's it!
Very Simple Steps.
In Xampp Control Panel Click on config of MySql then select "my.ini" file.
In this file add a line innodb_file_per_table=1 after [mysqld] line.
Now, I created a same database which you want to recovery like name as exam_table
Create one by one table which you want to restore like name as exam_time.
Run SQL query/queries ALTER TABLE `exam_time` DISCARD TABLESPACE;
Caution: This deletes the current .ibd file.
Copy the backup exam_time.frm & exam_time.ibd file to the appropriate database directory.
Run SQL query/queries ALTER TABLE tbl_name IMPORT TABLESPACE;
Check Your exam_time table its recovered .....Hurrahhh

How to export a MySQL database (data folder) from an hard disk?

I know, it is really sad trying to export a database just by copying the data folder! But I have a hard disk with an important database inside and I don't know how to export this database onto my actual system (winxp - mysql 5.0.37).
So, i've copied old_harddisk/program/mysql/data/coge2010 to mypc/programs/mysql/data/coge2010
Result:
I see cogemilla (4) on my phpMyAdmin databases summary (it's correct!!! my 4 tables!)
If I click the database, I see just 1 table (oh no!)
On the mysql error log file I find messages like this one: "...[ERROR] Cannot find table coge2010/soci from the internal data dictionary of InnoDB though the .frm file for the table exists. Maybe you have deleted and recreated InnoDB data files but have forgotten to delete the corresponding .frm files of InnoDB tables, or you have moved .frm files to another database? See http://dev.mysql.com/doc/refman/5.0/en/innodb-troubleshooting.html how you can resolve the problem."
Any ideas?
You should create a dump and import it on the new server.
In Command Prompt type the following to create the dumpfile:
mysqldump -h host -u user -p databaseName > dumpFile.sql
To import the database :
mysql -h host -u user -p databaseName < dumpFile.sql
You can only copy InnoDB tables if:
1. Your database is stopped.
2. You copy all InnoDB files (ibdata* ib_logfile* /*.ibd
You could use dump/restore to copy a single table.
You could user 'ALTER TABLE sometable ENGINE=MyISAM' to convert it to MyISAM and then copy the MYI,MYD and FRM.
Percona XtraBackup can do single table restores if you're using Percona Server.
This post may help you.
Another post which may help you.
A mysql table is defined by 3 files (FRM/MYD/MYI). In your case the FRM file is missing into the database folder.
If you can run the mysql server of the old hard disk it is easier to do a dump of your database. The following link shows you how to do this

PhpMyAdmin database somehow disappeared

Somehow the tables don't appear in phpMyAdmin anymore, but we checked the MySQL data table and the files seem to be there. I could not read them and did not recognize them as any of the available format for import.
At this point, what can I do to import the database with these files? (with extensions MYD .MYI .frm .opt.)
Your PHPMyAdmin configuration files could have changed. I'd check first from logging in from the command line:
mysql -u[USERNAME] -p -h[IPOFHOST],
so like this: mysql -uroot -p -hlocalhost (if your server is on localhost).
After logging in, run SHOW DATABASES; you should see your databases, type in USE [DATABASE_NAME]; for the database that you want to inspect, and then type in SHOW TABLES; and then you should see that your tables are still there.