LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I cant connect to the database, i need to set user privileges (https://www.linuxquestions.org/questions/linux-newbie-8/i-cant-connect-to-the-database-i-need-to-set-user-privileges-4175470272/)

tompa 07-19-2013 11:48 PM

I cant connect to the database, i need to set user privileges
 
I getting error on the site that i cant connect to the database ''Database connect failed''

My hosting provider already told me i have to set the privileges to user to the database and domain i think.

I have Debian and php 5.3.42. I using Fugo to connect to my VPS.

Any one can help me. Please explain very easy. I can manage to fix i it is easy.

Here is the error i get:

Database returned error "1142: DELETE command denied to user 'Example_user'@'localhost' for table 'user_properties' (localhost)".

j-ray 07-20-2013 02:55 AM

Welcome to LQ tompa!

Do you have ssh access to the machine where the database is running? What database is it? MySQl? The SQL statement to grant the delete right to user@localhost would be for MySQL

GRANT delete on DATABASENAME.* to 'Example_user'@'localhost' identified by 'SOMEPASSWORD'

In general you should provide us with more specific info.

Cheers
j

tompa 07-20-2013 03:02 AM

Yes i have full access to root and to MySQL.

I have an VPS and full root access.

I have Apache2 with Debian i think

I using mac and my Terminal to access to root. I already made many changes to the server like install Xcache and PHP admin and so on. But this one i can't figure out. My hosting only reply with bad answer that they don't do that for me.

I have 2 domain and one subdomain. If i create an database and make an install and after the install are finish i get error to open the front page or admin because i get the error on the header that say user is denied.

Database returned error "1142: DELETE command denied to user 'Example_user'@'localhost' for table 'user_properties' (localhost)".

If i only now how so can i sure make it my self. But it have to simple step by step.

tompa 07-20-2013 03:32 AM

Ok! The hosting send me this! But not more.

Login into the server > enter mysql command
Once login into mysql execute the below commands.
1. use mysql;
2. Execute the query \"select * from db where Db like \"databasename\";
3. Once you find that certain priveleges are not assigned, you can assign them using the below sql command
GRANT DELETE ON <database name>.* TO <database_user>@\'localhost\';
FLUSH PRIVILEGES;

Ok so i did this!

First i connect to my server and execute this.

mysql;

Ok i get messages that im in. Then i did this

\"select * from db where Db like \"my_database_name_here\";

But now i get error SQL syntax

What do i wrong here?

I

tompa 07-20-2013 03:53 AM

I did try now to set up a Mediawiki on my site and i get error when i trying to create a database


''Setting up database... failed''

Could not create database file /var/www/data/my_database_name.sqlite.

j-ray 07-20-2013 04:16 AM

Is there a directory /var/www/data on your server? If not create it
sudo mkdir /var/www/data
then change the owner of the directory to the web user
sudo chown wwwrun:www /var/www/data

Sydney 07-20-2013 04:28 AM

What your hosting company is not telling you, rightfully so. A database engine is going to require you to do some work to prepare a database for use. You will need to create a database on the database engine, the MYSQL engine can contain more than one database and the MYSQL database on the MYSQL database engine among other things controls user rights and access to each database, so you will need a user defined in the user table in the MYSQL database in the MYSQL database engine that gives rights to do some action to the database you create. Many tutorials are on the internet for setting up a user and a database, as well as the MYSQL site has a ton of documentation.

For your specific error, j-ray said how to add the DELETE privilege to your user, and your hosting provider mentioned the important step of FLUSH PRIVILEGES;. Why do you need DELETE to connect to the database though? You should not. I would first check to make sure you are using some other user (like one you create) besides root to connect to the database with your script. Then check your PHP script for a proper connection string, make sure it dies if no connection is established.

Your post about sqlite is a different issue, probably related to the creators rights, but should not be included in this string of posts.

tompa 07-20-2013 04:29 AM

Yes! Already have this directory /var/www/data

I have my other domains there to. But only one domain is working. The hosting did fix one for me. But now they don't do more they say. LoL

I also now tried to chmod the data to 755 but didn't help. I know i have to set owner privileges somewhere with the command they gave me but i can't figurer it how to do.

Any one? Please help.

tompa 07-20-2013 04:36 AM

Ok i did add this in to my terminal by that did not do anything. Could not find command?

GRANT delete on My_database_name.* to 'My_usename_here'@'localhost' identified by 'My_password_here'

Sydney 07-20-2013 04:43 AM

Code:

mysql -uroot -ppassword;
use mysql;
GRANT delete on My_database_name.* to 'My_usename_here'@'localhost' identified by 'My_password_here'
FLUSH PRIVILEGES;

password, My_database_name, My_usename, My_password_here are variables

j-ray 07-20-2013 07:01 AM

If you chmod the data directory to 0755 still the web user can't write to it. You have to chmod 0777 /var/www/data

but as Sydney said this is a different topic


All times are GMT -5. The time now is 04:01 AM.