LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 01-08-2004, 02:55 AM   #1
Hero Doug
Member
 
Registered: Jan 2004
Posts: 41

Rep: Reputation: 15
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.
 
Old 01-08-2004, 06:32 AM   #2
cheesy1979
LQ Newbie
 
Registered: Oct 2003
Location: Aberdeen, Scotland
Distribution: Fedora
Posts: 6

Rep: Reputation: 0
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
 
Old 01-08-2004, 01:26 PM   #3
Hero Doug
Member
 
Registered: Jan 2004
Posts: 41

Original Poster
Rep: Reputation: 15
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.
 
Old 01-08-2004, 05:56 PM   #4
cheesy1979
LQ Newbie
 
Registered: Oct 2003
Location: Aberdeen, Scotland
Distribution: Fedora
Posts: 6

Rep: Reputation: 0
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.
 
Old 01-08-2004, 07:19 PM   #5
Hero Doug
Member
 
Registered: Jan 2004
Posts: 41

Original Poster
Rep: Reputation: 15
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.
 
Old 01-08-2004, 11:59 PM   #6
Robert0380
LQ Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Rep: Reputation: 47
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.
 
Old 01-09-2004, 04:18 AM   #7
cheesy1979
LQ Newbie
 
Registered: Oct 2003
Location: Aberdeen, Scotland
Distribution: Fedora
Posts: 6

Rep: Reputation: 0
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!
 
Old 01-09-2004, 03:54 PM   #8
Hero Doug
Member
 
Registered: Jan 2004
Posts: 41

Original Poster
Rep: Reputation: 15
I actually found the answer on another forum. It has to do with setting up the MySQL super user first.

http://forums.devshed.com/showthread...88626#post4886
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 08:44 AM
where does 'su' look to determine if a user exists? MisterESauce Linux - Software 5 04-13-2005 09:18 AM
MySQL add user tommytomato Linux - Newbie 1 02-19-2004 10:24 AM
Connect to mysql as non root(linux) user dublinclontarf Slackware 1 02-09-2004 04:19 AM
How do I add a host user password to mysql server? cmisip Linux - Networking 3 12-16-2002 09:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration