How did my mysql database get deleted automatically? - mysql

I am very sure that i didn't delete my database and noone else sits on my machine. Then how did i my database get deleted automatically? I had 10 tables in it :(. Infact 2 databases got deleted automatically. They are not being shown in mysql query browser. How can i recover my databases back? Is there any query which will help to show the logs to see if the delete schema command was actually fired in mysql? I am very much frustrated. Please help. The last time i saw these database alive was before 2 weeks and today they are no more.

could be you are looking at them with a different user credentials that does not have sufficient privileges to see them?
What tool are you using to view them? command line, phpmyadmin etc?
Yes there are logs you can go through see here

Your database is not deleted from MySQL. You would have set your own user and password in user table when you created these tables. However the when You open my SQL it takes root as the user by default and password as NULL. So to fix it and to see your database and tables you need to set your username and password in config file of MySql.
Example:- If your username and password is XYZ you need to set them as below in config file(config.inc).
path for this file would be:-C:\wamp\apps\phpmyadmin4.1.14 (depending on the version you have installed)
$cfg['Servers'][$i]['user'] = 'XYZ';
$cfg['Servers'][$i]['password'] = 'XYZ';

We had similar problem where we lost all the tables of the database but the database remains as it is in the mysql. The problem and the solution is as follows:
Check where you have installed your MYSQL/XAMPP/WAMP
Check whether you have all the permissions to install the MYSQL/XAMPP at the
place where you have installed your XAMPP/MYSQL on your desktop/server.
The solutions is simple, just re-install your XAMPP/MYSQL on your desktop/any other location where you have permission to install.
Your will not get this problem in future.
Please do not forget to check your error logs and take necessary actions after checking logs daily.

Related

MySql tables disappeared and showing a table named as 'warning'

We were having a MySql Server running in Azure Windows Virtual Machine. We were not using it for the past 6 months. But recently we logged into the Virtual Machine and tried to access the database using MySql Work Bench. But it doesn't accept the password and we were unable to login. So we changed the root password by following the instructions from MySql documentation (Resetting the Root Password: Windows Systems).
Based on the instructions, the following commands were executed to reset the password:
CD C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe
mysqld --no-defaults --datadir="C:\\ProgramData\\MySQL\\MySQL Server 5.7\\Data" --init-file=C:\\mysql-init.txt
After running the command, we were able to resect the password and logged into the Mysql as a Root user via the workbench. But, There were no tables other than tabled named as 'warning' in the databases. Following is the screenshot from the MySql Workbench. You can see the 'warning' tables is having four fields namely id, warning, Bitcoin_Address, and email. But there are no rows having values for these fields.
Is there anyone who knows what is exactly happened here? Any way to recover the missing tables? We were not having any other backup for these databases.
After 1 year 15 days. Most probably you have been hacked. I too had this issue in my raspberry pi server, which I used for the weather monitoring. But thanks don't have that important data to pay for it. Before coming to the conclusion check a few things.
How To Fix Corrupted Tables in MySQL, If not solved then,
log in to your mysql database in the terminal, query SHOW database, query USE database_name, query SHOW TABLES;
as mentioned, if you see only one table named WARNING,
Then, query CHECK TABLE `WARNING`;
In the displayed table, if you see under column Msg_text = OK
Then, query SELECT * FROM `WARNING`;
There you have your answer, A hacker has hacked your database, and is demanding money in bitcoin.
Solution: I don't trust them, they will not return your data. Best don't fall for the trap. Instead, use a strong password in your database, use ssh in your site (if you are using), use a python script to daily backup your database through CRON task.
Sorry, If you are a victim of a hacker. I cannot be of much help then.

mysql information_schema empty and not populating

Running WAMP localhost server With php 5.6.18 and MySQL 5.7.11 In project that im working on now i need to get some column data form information_schema.COLUMNS table, but information_schema DB is completely empty - 0 rows for every table in this DB For additional information - I have like 10 differnet DB on this MySQL, some are imported some are made from scratch in phpmyadmin.So im completely lost - tried to google but no luck.Maybe i miss something essential and trivial like some configuration of MySQL?
Execute this query:
mysql> SHOW GRANTS;
This will show you that either you are not logging in as the user you intend to use, or that this user lacks permissions on the tables in question.
In this case, the user may have no permissions at all. MySQL has a special permission called USAGE, which may seem slightly deceptively named if you aren't familiar with what it means. It means you can "use" the server -- that is, you can log in. But that is all it means. If you possess only the USAGE ON *.* privilege, this means you have permission to log in to the server, but no permissions on anything else.
The information_schema is integrated with the permissions system. You can't see information about database objects for which you don't have permissions. An empty information_schema.columns table suggests a permissions issue for the user you are using to connect to the server.
Sometimes this may be issue when you copy and paste the database's folders in mysql folder. Don't copy that way. The best way to export the databases using "export" command in "phpmyadmin" or use "mysqldump" command in mysql command line client to copy the data or export data from one to another.It will generate "yourdata.sql" file at the last , You can import that data using "export command in "phpmyadmin" . In your method is successful for "MyISAM" database driver in mysql. Modern mysql servers default database driver is "InnoDB" and it not success in when copy the database data folder on to another machine. If you have copy of previous copy of the databases from the old machine, try to export the "yourdata.sql" file using export method in "phpmyadmin" web interface.
I faced same problem when I transfer/shifted my mysql folder to other location.
And configured DB to point Mysql folder accordingly.
However, Information_schema was not getting updated though rest DB queries were running fine.I could't find proper solution but the way around was from mysql editor (like workbench) do inspect schema.
You will get an option in bottom to 'Information Outdated' and then click on Analyze table. You will find that Information_schema start calculating correct size and other details.

Mysql is not working correctly

Hello Stackoverflow,
I was trying to connect to my MySQL database through Coda 2. I connected, created a database called 'database1' (for example), then I tried to create a table called 'user', but I get this error:
MySQL said: Table 'user' is read only
I was surprised because it had worked previously with other databases long time ago. I went to my xampp files, //xampp/mysql/data/database1/ and then I found out that user.ibd is there alone. So I first tried to change the properties of the files by disabling read-only. The problem is that when I did that, close the properties windows, and opened again I would get the read-only check box on. So I gave up on that. So I said ok, I will just create the database from my server instead. So I when to phpmyadmin, I see that database1 is created but there is no table called 'user'. So I try to create a table and I get this error:
#1813 - Tablespace for table '`database1`.`user`' exists. Please DISCARD the tablespace before IMPORT.
I then I found out I cannot even do much with phpmyadmin from my server. I tried reinstalling xampp, but it was impossible for me to remove the origianal because it was "already" in use. Please help me and thank you!
EDIT: I can apparently create databases but not tables. Just to clear that up.
You can try using CLI and logged into mysql and create a new database and a table. If it's working, there's something wrong with your phpmyadmin not mysql. Make sure you logged in as the same user (whom have root privileges) when creating the database and table.

Mysql Grant with option to skip a db

One of my db have tables around 10000(temporary use).
But what it has done that opening phpmyadmin become slow and my version is "2.6.0-pl2".
Because of this version I cannot use skip_db option of phpmyadmin.
So I decided to have a new user with permission to all database except one but I don't know how to do that.
So can someone tell me how to write grant to all db with skipping just one db ?
There is no need to create a user for this problem.
use show database command and you will get list of db.
In phpmyadmin version "2.6.0-pl2" , you can use show_db variable and set all tables there are your problem will be solved

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.