MySql can't create table errno 121 – Solution!

MySql can't create table errno 121If you are working frequently with MySql databases, it is more likely that you have got this error many times. If you're reading this article to find how to solve this error, you are in the right place. Keep on reading to know how you will get this error and how you can solve this without getting any headaches :)

For those who haven't seen this before, here is the full error message:

Error 1005: Can't create table '' (errno: 121)

I wanted to find an exact solution for this error and write it on my blog so that it will be a reference for others as well.

I referred to the MySql documentation and found this doc, and this error comes under the InnoDB errors section. So now we know this has something to do with InnoDB. Let's read the documentation a little more :)

As the documentation states;

14.21.5 InnoDB Error Codes

The following is a nonexhaustive list of common InnoDB-specific errors that you may encounter, with information about why each occurs and how to resolve the problem.

1005 (ER_CANT_CREATE_TABLE)
Cannot create table. If the error message refers to error 150, table creation failed because a foreign key constraint was not correctly formed. If the error message refers to error –1, table creation probably failed because the table includes a column name that matched the name of an internal InnoDB table.
….........

This is it! The error code is 1005, but it says only about the error 150, which is a different case. I went through the comments and found some nice tips.

Reason for getting Error 1005: Can't create table (errno: 121):


You will get this error if you are trying to add a constraint name that is already used in somewhere else.

As it turns out, you can't have two foreign key constraints with the same name. Simply that's the issue.

If you are getting this error while adding a foreign key to a table, that means you have used that constraint in another table. So just make sure to change the name of your foreign key constraint and save the table. It will work nicely if you have no other conflicts. :)

How to know where else you have used this constraint?
You can run the following query to see where else your constraint is used. I found this in a stackoverflow answer.

SELECT
    constraint_name,
    table_name
FROM
    information_schema.table_constraints
WHERE
    constraint_type = 'FOREIGN KEY'
AND table_schema = DATABASE()
ORDER BY
    constraint_name;


I hope this article will help you to get this error solved! Please do not forget to share this with your friends on Google+, Twitter or Facebook if you think this will be useful to them too :)

Ubuntu system program problem detected - Fix

Ubuntu System program problem detected


Here is another interesting thing! I'm sure many of you have already seen this before or will see after me. This is also another error I came across while using Ubuntu, and I actually have no idea what caused it. It's been popping up since few days..and actually I can't remember what I did. But apparently there was nothing wrong in the system in terms of functionality.

Every time I log into Ubuntu, I'm getting a Pop up with an error message.

This is what the pop up says :
System program problem detected
Do you want to report the problem now?

There's a button to close the pop up and another one to report this problem to Ubuntu developers. But reporting the problem doesn't make any change either. It might get reported, but still you get the pop up every day when you log in. It becomes annoying after some time. If you have reported this, and want to get rid of the pop up, please read the below paragraphs to fix this error. I've shown how I fixed it.

What did the Pop up really say?


Before you start fixing the error, you should have an idea about the error and how it occurs. (Actually the steps to fix it is really simple!). In Ubuntu, there's a program called Apport, and its task in simple words is to act upon any problem occur in the system and collect information about it, and report it to the user with the steps the user need to follow.

As the Ubuntu Wiki says,

Apport is a system which
  •     intercepts crashes right when they happen the first time,
  •     gathers potentially useful information about the crash and the OS environment,
  •     can be automatically invoked for unhandled exceptions in other programming languages (e. g. in Ubuntu this is done for Python),
  •     can be automatically invoked for other problems that can be automatically detected (e. g. Ubuntu automatically detects and reports package installation/upgrade failures from update-manager),
  •     presents a UI that informs the user about the crash and instructs them on how to proceed,
  •     and is able to file non-crash bug reports about software, so that developers still get information about package versions, OS version etc.

We are sure that this will lead to a much better level of quality assurance in the future.

Read more about Apport in the Ubuntu Wiki.

So basically, whenever your system encounters a crash/problem in a system program or any other, the system actually makes a crash report in a system directory. As the Wiki says, the Apport  program will look for these and keep you informed about the crash until you take necessary actions to fix it.

How to know what program has caused the problem ?


This is a good question indeed. You get the message saying that a system program has crashed, But what is it?

You can see what crash reports are generating the pop up. These crash reports are saved in the /var/crash directory. Open that directory to see the current crash reports. Don't try to open the report :) You wouldn't want to do it unless you are planning to do any debugging. (Here is the Ubuntu Wiki article if you really want to open that file and debug.)

If you are an ordinary user like me, just read the name of the report and try to get an idea like which software has caused it. There's nothing much we can do about those :)

How to get rid of the pop up?


Here is the main section of this article.

In order to fix this error, what you have to do is clear the existing crash reports in your system so that Apport will not find anything to report.

Here's how to do it.

Step 01: Open up your terminal. (press ctrl + alt + T)
Step 02: Enter the following command into the terminal.

sudo rm /var/crash/*

What we do here is clear the whole content of the /var/crash/ directory.

Done!

Now when you log in next time, there won't be any pop ups saying System Program problem detected etc.

Other ways to fix the System Program problem detected error.


Following the above method, you should know that we are actually clearing the crash reports existing in the system to overcome the pop up message. But in the future, if any System program crashes and makes any problem, the Apport will start to show this message again. You can follow the same method to fix it.

But if you are not that much serious about system errors, and if you think you don't want to get this kind of errors reported, you can simply disable the Apport. Then you will not get these error notifications.

To disable this, you only have to change a small configuration value for Apport.

Step 01: Open your terminal (press ctrl + alt + T)
Step 02: Enter the following commands.

sudo gedit /etc/default/apport

as you know, it will now ask for your password. Enter it.

This will open the apport's configuration file in Gedit.

The content of the file will be similar to this;

# set this to 0 to disable apport, or to 1 to enable it
# you can temporarily override this with
# sudo service apport start force_start=1
enabled=1

Step 02: Change enabled=1 to enabled=0:

# set this to 0 to disable apport, or to 1 to enable it
# you can temporarily override this with
# sudo service apport start force_start=1
enabled=0

and save the file.

Step 04: Restart or stop the Apport service. Both will work, you will not get any error notifications anymore because it is disabled.

sudo restart apport

Cheers! You just fixed your annoying problem :)

Note: Even though I have shown you how to disable Apport, I don't recommend you to disable it.  You may not be interested in getting errors reported to you, but it helps you to stay alerted about the changes happening inside the system. You will know whenever a system program or any other software causes any problem. It will be really helpful for you to get them fixed sometimes even by yourself, because you know actually where the error is originated. So think twice before you do it :)

Also please note that you have not actually fixed the error which apport reports to you. What you actually do is stop Apport from reporting about the crashes in your system. The crash is actually not solved. So if you want to fix the error itself, you will have to dig some more..If you are interested, please follow the link I given above regarding the crash debugging.

If you find this article useful, please feel free to share this story with your friends in Google+, Twitter or Facebook!

Shake your logo a little with a simple CSS3 animation!

I just wanted to write this blog post to get your attention to the logo of my blog :)



If you take your mouse pointer over the logo above, you will see a really simple animation I have added to it. Why don't you try it now? :) I said “simple” because it's very easy to do and you only need to add a few new lines to your style sheet. I will show you how to do it.

Also note, I'm going to show you how this animation can be included in a blogspot blog because I know there are hundreds of similar articles written about CSS3 animations and probably many of those articles will already have about this animation too. So there's no point of repeating the same thing, instead I will show you how to add this in your blogspot blog to add some value to this article. Don't worry, the blogspot part is only a addition to this article. You can use the styles in your website too.

Let's Start.

01. First login to your blogger account and go to “Templates” option.
02. Click on the “Edit HTML” button.


03. This will open the source of your template to edit. Press ctrl + F key and search for

        <style type='text/css'>






04. When you find it, insert the following css rules under that line in your template source.

@keyframes shake-logo{
16.65% {
    transform: translateX(8px);
}
33.3% {
    transform: translateX(-6px);
}
49.95% {
    transform: translateX(4px);
}
66.6% {
    transform: translateX(-2px);
}
83.25% {
    transform: translateX(1px);
}
100% {
    transform: translateX(0px);
}
}

.logo:hover, .logo:focus, .logo:active {
    animation-duration: 1s;
    animation-iteration-count: 1;
    animation-name: shake-logo;
    animation-timing-function: ease-in-out;
}





here “.logo” is the class name I've applied to my logo. Remember to add the class “logo” to your logo first. Otherwise this won't work.

I think I don't need to explain the code?

Here the main thing is in the “@keyframes shake-logo“ line. We first define an animation using the CSS keyframes rule, and give it a name as “shake-logo”.

After that we have assigned the animation to our .logo class using the animation-name: shake-logo; property.  Other properties are self explanatory.

So, that's it! Now open your website/blog and see!

Actually what I have shown you here is only the basic application of this animation. So probably this won't work in webkit browsers like Chrome / Safari or Opera ;)

Read the following articles from W3schools and learn how you can overcome this too.

http://www.w3schools.com/css/css3_animations.asp
http://www.w3schools.com/cssref/css3_pr_animation.asp

Hope you enjoyed my article. Do you think I've missed anything? Please feel free to let me know in a comment below.

A simple show / hide password function using Javascript.


We all know that password boxes in any web/desktop applications are masked with an asterisk (*) to protect it from being exposed to others while you type it. But sometimes have you noticed that when you enter your password to connect to a Wi-Fi network, there is a check-box which allows you to view the password that you typed in plain text? That is to make sure
you have entered your password correctly, so you can connect to the network in the first attempt.

I think it's a nice feature to have in any application. But in terms of security, it will not be nice :-)

Anyway, I just liked it and I wanted to make a little login page with that option included. Here is the Javascript function. It's too simple. I'm not even thinking to include this feature in any of my real applications though :-)

Note : Having your password exposed to someone else will make dangerous things happen! Therefore you should never let anybody know your passwords of important and private accounts like Gmail, Facebook etc. A person can even guess your password by looking at the keyboard while you type, and the number of asterisks that appear in the password box. Therefore be conscious.

Here is the code.

Pasword : <input type="password" name="password" id="password" />

<br/>

<input type="checkbox" value="1" name="reveal" id="reveal" onchange="reveal_pass(this); "> Show Password

<script type="text/javascript">

function reveal_pass(check_box){

    var textbox_elem = document.getElementById("password");

    if(check_box.checked)

    textbox_elem.setAttribute("type", "text");

    else

    textbox_elem.setAttribute("type", "password");

}

</script>



Here is a Demo :-)

Pasword :
Show Password


What do you think about the protection of your passwords? Do you think this is a good idea or a bad idea?