Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
01-08-2004, 02:55 AM
|
#1
|
Member
Registered: Jan 2004
Posts: 41
Rep:
|
MySQL db exists, can't connect to it, do I need to add user to it?
I'm using Fedora, but I don't think it'll matter.
Anyways I made a database from the command line, but when I try to access it access is always denied. Do I need to add a user to it, set permissions etc?
If so, how to I do it?
Thanks.
|
|
|
01-08-2004, 06:32 AM
|
#2
|
LQ Newbie
Registered: Oct 2003
Location: Aberdeen, Scotland
Distribution: Fedora
Posts: 6
Rep:
|
You need to tell us more info!! Hope this doesn't sound patronising.
Assuming you're using the command line:
Is the server running? ie, mysqld_safe
Are you logged in (ie you get the "mysql>" prompt)?
If so, what command are you using? ie, mysql -uroot -prootpassword
Tell us the exact commands you are using and the exact error messages.
Cheesy
|
|
|
01-08-2004, 01:26 PM
|
#3
|
Member
Registered: Jan 2004
Posts: 41
Original Poster
Rep:
|
I was in the terminal when I made the db, i used the following command to make the db.
mysqladmin create search
I know it exists because I thought it might have not made it the first time and I tried it again, it gave me a message saying the db already exists.
This is the command I used to connect to it.
$con = mysql_connect("localhost")or die("Couldn't connect to MySQL server. Please send the following information to the site admin. <br /><br />: ".mysql_error());
$db = "search";
mysql_select_db($db, $con)or die("Connect Error: ".mysql_error());
I;ve also tried puting the root username and password in the connection variable, no luck.
This is the error
Connect Error: Access denied for user: '@localhost' to database 'search'
Last edited by Hero Doug; 01-08-2004 at 01:28 PM.
|
|
|
01-08-2004, 05:56 PM
|
#4
|
LQ Newbie
Registered: Oct 2003
Location: Aberdeen, Scotland
Distribution: Fedora
Posts: 6
Rep:
|
You seem to be connecting to the server ok but don't have any privileges for your database which I can't understand because the root user should work on any database.
Also, the error message is intriguing. The user name is missing. Have you typed the complete error message below? It should tell you something like:
Connect Error: Access denied for user: 'root@localhost' to database 'search'
I suggest trying this- it can't hurt! It creates a new user called admin, with the password adminpass, who has privileges to do anything to your search database.
from the command line log-in to the server as the root:
mysql -uroot -proot'spassword
enter the following command:
grant all privileges on search.* admin@localhost identified by 'adminpass' with grant option;
logout:
\q;
change the mysql_connect("localhost") in your php script to:
mysql_connect("localhost","admin","adminpass")
If that doesn't work then I'm stuck. Like I said before, I don't understand why it doesn't work as root.
Last edited by cheesy1979; 01-08-2004 at 05:58 PM.
|
|
|
01-08-2004, 07:19 PM
|
#5
|
Member
Registered: Jan 2004
Posts: 41
Original Poster
Rep:
|
Maybe I need to make a database with all the users in it first!
I've tried adding my normal account to the mysql group, and I've tried to connect to the server as both root and the normal account, from both php scripts and the command line. Both were denied.
I can make a connection to the server as anyone, but as soon as I try to access a database all access is denied.
After I got to the mysql command prompt and tried toenter the code you posted, which produced an error.
ERROR 1064: You have an error in your SQL syntax near 'herodoug@localhost identified by pass with grant option' at line 1
Is there any way to display all the databases there currently are? (Hopefully I'll have founf the answer by the time you respond)
I was right, I did find the answer before anyone responded. There are three databases.
mysql
search
test
Last edited by Hero Doug; 01-08-2004 at 07:22 PM.
|
|
|
01-08-2004, 11:59 PM
|
#6
|
LQ Guru
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280
Rep:
|
grant all privileges on search.* admin@localhost identified by 'adminpass' with grant option;
i think you need to add the word "to"
grant all privileges on serach.* to admin@localhost
try it with "to".
here is the link:
http://www.mysql.com/doc/en/GRANT.html
Last edited by Robert0380; 01-09-2004 at 12:00 AM.
|
|
|
01-09-2004, 04:18 AM
|
#7
|
LQ Newbie
Registered: Oct 2003
Location: Aberdeen, Scotland
Distribution: Fedora
Posts: 6
Rep:
|
Oops!
Doh! As Bob said I forgot the 'to'. Try
grant all privileges on search.* to admin@localhost identified by 'adminpass' with grant option;
If that don't work then I'm stumped!
|
|
|
All times are GMT -5. The time now is 02:44 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|