Mysql Queries in Linux

How to resolve mysql_connect() Error

Warning: mysql_connect() [function.mysql-connect]: Access denied for user ‘username’@’localhost’ (using password: YES)

Possible root cause for this problem is proper priviliges not assigned to the particular user. So providing proper previliges will solve this issue.

$grant all priviliges on “Database_Name” to “username@localhost” identified by “password”

If the mysql resides in the same server then we will use “user_name@localhost”, to identify the user and

If the mysql resides in different server then we will use “user_name@%” to identify the user.

To check whether database is connecting with the user use the following command

$ mysql -u username -p

Enter the password:

MySQL connects with the server.

Thus the error is resolved

Note :

$ represents command should be entered in the terminal

How to restore database from mysql

To restore database from mysql file you should first enter into mysql via following command

$mysql

Then execute the below command to restore database

$mysql sqlfolder < filename.sql

How to take MySql dump in Server

Commands to take mysql dump in the server

1. Enter into mysql via the following command.

$mysql

2. Then dump mysql to some “filname.mysql” via the following command.
$mysqldump sqlfolder > filename.mysql