Lost MySQL ROOT Password ??? Don’t Worry. Here is the trick to Reset it !!!

Worrying of LOST the ROOT Password. Don’t have to worry. Here is the trick, to get it solved and recover the reset the password, so that you can login to MySQL again.

Firstly, stop theMySQL Server as below:

# /etc/init.d/mysql stop

Then start the MySQLD daemon with -skip-grant-tables as shown below:

# mysqld_safe --skip-grant-tables &

Now Connect to MySQL server as shown below with the root user:

# mysql -u root

Now you can reset the password with your choice as shown below:

mysql> use mysql;

mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';

mysql> flush privileges;

mysql> quit

Now exit from the MySQL prompt and Stop the MySQL server as shown below:

# /etc/init.d/mysql stop

Start the MySQL Server:

# /etc/init.d/mysql start

Connect to the MySQL database server as shown the below with root user and the password you set.

# mysql -u root -p

Popularity: 51% [?]

MySQL Database backup and restore

As the database is a critical thing to handle, one needs to monitor and take backups periodically. For this following command is used to take backup of MySQL Database.

#mysqldump -u user_name -p pass_word db_name > db_name.sql

For restoring the database from the backup file:

#mysql -u root -p root_password db_name < db_name.sql

Powered by ScribeFire.

Popularity: 51% [?]

Grant Privileges to User for a Particular Database

If you are not giving the below said privileges to the user, then you
can only give permissions to appropriate database as shown below:

mysql> grant all privileges on guest.* to
    -> 'guest'@'localhost' identified
    -> by '1234567890' with grant option;

mysql> flush privileges;

Here ‘guest’ is the Database name and ‘guest.*’ means granting the permissions to all the tables in that database.

Powered by ScribeFire.

Popularity: 42% [?]

Create Users in MySQL ???

For adding a new user to MySQL you just need to add a new entry to user table in database mysql. Login as root to mysql as shown below:

$ mysql -u root -p   (if Root Password is set.) 

$ mysql -u root (If password is not set for root)
It is recommended to have password for root. To set up
password for root, check out the previous post.

Below is an example of adding new user ‘user_name’ with SELECT, INSERT
and UPDATE privileges with the password ‘mypass’ the SQL query is :

mysql> use mysql;
Database changed

mysql> INSERT INTO user (host, user, password, select_priv,
    -> insert_priv, update_priv) VALUES('localhost','phpcake',
    -> PASSWORD('mypass'), 'Y', 'Y', 'Y');
Query OK, 1 row affected (0.20 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 1 row affected (0.01 sec)

mysql> SELECT host, user, password FROM user WHERE
    -> user = 'phpcake';
+-----------+---------+------------------+
| host      | user    | password         |
+-----------+---------+------------------+
| localhost | phpcake | 6f8c114b58f2ce9e |
+-----------+---------+------------------+
1 row in set (0.00 sec)

When adding a new user remember to encrypt the new password using
PASSWORD() function provided by MySQL. As you can see in the above
example the password mypass is encrypted to 6f8c114b58f2ce9e.

Notice the the FLUSH PRIVILEGES statement. This tells the
server to reload the grant tables. If you don’t use it then you won’t
be able to connect to mysql using the new user account (at least until
the server is reloaded).

You can also specify other privileges to a new user by setting
the values of these columns in user table to ‘Y’ when executing the
INSERT query :

  * Select_priv
  * Insert_priv
  * Update_priv
  * Delete_priv
  * Create_priv
  * Drop_priv
  * Reload_priv
  * Shutdown_priv
  * Process_priv
  * File_priv
  * Grant_priv
  * References_priv
  * Index_priv
  * Alter_priv

I think you can guess what those privileges serve by reading it’s name

Powered by ScribeFire.

Popularity: 40% [?]

How to Setup ROOT Password and User Password for First Time.

Method 1#If you have never set a root password for MySQL, the server does not
require a password at all for connecting as root. To setup root
password for first time, use mysqladmin command at shell prompt as
follows:
       

 $ mysqladmin -u root password NEWPASSWORD

However if you want to change (or update) a root password, then you need to use following command:

 $ mysqladmin -u root -p oldpassword newpass

Enter password:

To change a normal user password you need to type (let us assume you would like to change password for Suresh):

     $ mysqladmin -u suresh -p oldpassword newpass

Method #2: MySQL stores username and passwords in user table inside
MySQL database. You can directly update password using following method
to update or change password for user suresh:

  1. Login to mysql server, type following command at shell prompt:
     $ mysql -u root -p

   2. Use mysql database (type command at mysql> prompt):

      mysql> use mysql;

   3. Change password for user suresh:

      mysql> update user set password=PASSWORD("NEWPASSWORD") where User='suresh';

   4. Reload privileges (very important):

      mysql> flush privileges;

      mysql> quit

Powered by ScribeFire.

Popularity: 43% [?]

Close
E-mail It
Blogarama - The Blog Directory Directory of Computers/Tech Blogs Add to Technorati Favorites Find Blogs in the Blog
Directory Software blogs Top Blogs British Blog Directory. FindingBlog - Blog Directory blog search directory blog sweet blogoriffic.com Top100 Bloggers - Top Blog Directory - Blog Top list Blogs Blog Directory 5starblogs Age less highclassblogs.com kmax.ws Blog Directory & Search engine Blogs Directory All-Blogs.net directory Webfeed (RSS/ATOM/RDF) registered at http://www.feeds4all.com Business Blogs & Directory LS Blogs

Rate Me on BlogHop.com!
the best pretty good okay pretty bad the worst help?

-->