MySQL db exists, can't connect to it, do I need to add user to it?
Linux - GeneralThis 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.
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.
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?
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'
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.