|
-
Jul 16th, 2009, 12:36 PM
#1
Thread Starter
Lively Member
[RESOLVED] mysql database user
It might be a stupid question, but is a question nonetheless. On my desktop with wampserver on, I have been connecting to all the databases with a common username and password.
PHP Code:
mysql_connect("localhost","root","password")
When I create database on the server hosting my site, I realize that I can't have same username for two databases. In my php files, I had used the above code to establish connection to whichever database I required. Now, I will have to alter the code specifically for each of the databases.
Is there an alternative to this? Can I use localhost and root on my server?
Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic
-
Jul 16th, 2009, 01:05 PM
#2
Re: mysql database user
Create a user and give them access to the databases.
Users should never be using root access to access your databases. Limiting them to the basics of what they need is best.
If you have phpMyAdmin, it has a fairly simple interface to achieve this.
-
Jul 16th, 2009, 03:21 PM
#3
Re: mysql database user
You can usually still use "localhost" for the connection, unless your host specifies something else. And you know that mysql_connect() isn't what selects your database, right? mysql_select_db() does that. I believe you can, in fact, have the same login work for multiple databases if it has permissions to both.
As kfcSmitty said, you should never have your scripts connecting as "root," the problem being that it has full access to your database: it can read from, write to, truncate, or drop any table in the database. You want to limit access to curtail the malicious things that can be done.
Last edited by SambaNeko; Jul 16th, 2009 at 03:25 PM.
-
Jul 18th, 2009, 08:47 AM
#4
Thread Starter
Lively Member
Re: mysql database user
Thanks to both of you.
I might not get rights on localhost on the server, so I decided to have separate users of databases even though I had to type few more lines of codes.
Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|