Webhosting Blog

Use mysql and mysqldump with out providing passwords.


In order to issue administrative commands related to mysql you need to provide the username and password for the user.

You can issue the mysql administrative commands without the username and password. For this you can follow following steps.

1) Login to the server as root.

2)To login with out password, create a file /root/.my.cnf.

[root@server~]# vi /root.my.cnf

3) Add the following contents to the file.

[mysql]

user = root

password = FfRBehWy

[mysqldump]

user = root

password = FfRBehWy

Save the file.

4) Ensure the file permissions are set 600.

[root@server~]# chmod 600 /root/.my.cnf

5)Now you can issue the mysql and mysqldump commands without issuing the user name and passwords.

6)Try it out.

[root@server~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1239032
Server version: 5.0.91-community MySQL Community Edition (GPL)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s