Reputation: 23
I can't seem to access the database to my host's server. Here's the code that I use to connect to it:
$servHost = 'fdb7.biz.nf';
$servPort = '3306';
$servName = '1598934_user';
$servPass = '**********';
$dataTable = 'table';
$connect = @mysql_connect($servHost.':'.$servPort, $servName, $servPass);
$db = @mysql_select_db($dataTable);
if(!$connect || !$db){
die(mysql_error());
}else{
echo 'connected';
}
When I try to use this I get the error:
Access denied for user '1598934_user'@'%' to database 'table'
I assume it has something to do with the %
sign, but I don't know what to replace it with or how. The server is not mine, I'm using biz.nf to host my site. Any advice appreciated.
Upvotes: 1
Views: 1206
Reputation: 2728
Check if the user 1598934_user exists in the database. If it does exists, run the following mysql query to grant privileges.
GRANT ALL PRIVILEGES ON `postsData`.* TO '1598934_user'@'%';
FLUSH PRIVILEGES;
or if you do not want to grant all privileges then use:
GRANT <privileges> ON postsData.* TO '1598934_user'@'%' IDENTIFIED BY 'password';
or use:
GRANT INSERT, SELECT, DELETE, UPDATE ON postsData.* TO '1598934_user'@'%' IDENTIFIED BY 'password';
This should give privileges to the user
Also, if the user does not exists follow the query:
CREATE USER '1598934_user'@'%' IDENTIFIED BY 'password';
and follow the grant privileges query to give privileges.
Also, if you do not have access to run the above queries, use server name as localhost
and upload your site contents / files to the host and run from the host.
Upvotes: 1