Archive for Mysql

Reset your local wordpress password easily

If you forget  your wordpress password then what can you do?

Answer is here…………….Two easy methods

First Method

start mysql and login
SELECT ‘wordpress’ //this should be your database name
UPDATE `wp_users` SET `user_pass` = MD5( ‘password’ ) WHERE `ID` =1 LIMIT 1 ;

where password is your new password. Your password is reset, for the admin acount.

Second Method

Using Phpmyadmin……

By using phpmyadmin find out the wp-user table and admin user .

You will notice the password is strange, and not plain text. This is because for security reasons, WordPress stores the passwords as an MD5 hash.

We can’t just enter a normal text password, and should replace the MD5 hash of the password we don’t know with the MD5 hash of a password we do know.

To create an MD5 hash, I usually just search for “online MD5 hash” on Google, and come up with some great online tools for creating the result I need.

Example: Javacript MD5

n such tools, I enter what I want the password to be, click a button to process it, and it spits out the MD5 hash that I want to enter in the user_pass field.

Click Go to save the change, and then log in to WordPress using your new password.

Enjoy

Leave a Comment

How to dump a mysql database as a bzip file?

Use this command:

mysqldump -u <username> -p<password> -q <database> | bzip2 -c > filename.sql.bz2

Leave a Comment

How to set default character set as UTF8 when importing a mysql database?

Normally, when importing a mysql database default character set will be UTF8. If not,
we can set it manually with the below methods….

1. mysql -u <username> -p –default_character_set ‘utf8′ databasename < database.sql(exported database).

2. if you are using a compressed file, then use…
1. If bzip2:
bzip2 -cd <database.bz2> | mysql –host=localhost –user=<username> -p<password> –default_character_set ‘utf8′ <database name>

This can be done easily by using phpmyadmin.When importing a database just select UTF8 from the below select box named ‘character set of the file’.

Leave a Comment

How to delete or drop all tables from a mysql database?

We can drop tables using the query “droptable table name;”. We van do it only one by one.So this is impractical when there is lot of tables. In such situation we can use the below given command:

mysql -u <username> -p<password> <database name> -e “show tables” | grep -v Tables_in | grep -v “+” | \gawk ‘{print “drop table ” $1 “;”}’ | mysql -u <username> -p<password> <database name>

Commonly arising problems:

1. gawk(Gnu awk): you must install this module.gawk is a pattern cheking language.
2. If you give password with this command(in the place of <password> you may avoid the space between -p and password.

Leave a Comment