Koozali.org: home of the SME Server

PHP script w/ MySql

Lance Stuetzle

PHP script w/ MySql
« on: June 04, 2001, 02:10:19 AM »
Getting this message when trying to connect to MySql with a PHP script.

Warning: MySQL Connection Failed: Access denied for user: 'root@localhost' (Using password: YES) in /home/e-smith/files/ibays/lancest/html/MySqlcon.php3 on line 13
Do i need to create another user? I can't seem to accomplish this, have tried.
Other non MySql scripts run. Thanks.

           
                            L.S.

Mahmood Al-Yousif

Re: PHP script w/ MySql
« Reply #1 on: June 04, 2001, 02:25:18 AM »
can you connect to MySQL normally:

  host> mysql

and it runs? or do you have to supply a root password?

You can find your root password in /root/.my.cnf

then do from a shell:

   mysql -uroot -prootpassword

and see if you connect. If all goes well, you might have to edit your php3 script and plug in the right values in the    mysql_select()   statement.

hope this helps
mahmood

Lance Stuetzle

Re: PHP script w/ MySql
« Reply #2 on: June 09, 2001, 05:00:35 AM »
Yes I can connect to MySQL as root (no password), using telnet from windows. Would I connect to localhost? Connection params might be wrong.

Lance Stuetzle

Re: PHP script w/ MySql
« Reply #3 on: June 09, 2001, 05:00:36 AM »
Yes I can connect to MySQL as root (no password), using telnet from windows. Would I connect to localhost? Connection params might be wrong.

Mahmood Al-Yousif

Re: PHP script w/ MySql
« Reply #4 on: June 09, 2001, 08:28:05 PM »
[quote:]MySqlcon.php3 on line 13[endquote]

If you look into the MySqlcon.php3, you might see definitions there that you have to change, if you are happy enough to connect as root without a password, then change the definitions at the top of the file (usually).

Normally you would set:
  host as localhost
  dbuser as a user you have defined in the MySQL database
  dbpassword is the password you have defined for the user above

The easiest way to manage MySQL is to use something like Webmin or MyPHPAdmin scripts. You can find these utilities on the net: I know that you can pick up Webmin from www.webmin.org.  CAUTION: e-Smith does NOT recommend that you use this, as improper use can damage your e-Smith installation irreperably! So be careful, unless you know what you're doing.

If you are not experienced, then use MyPHPAdmin, safer!! (sorry, I'm not being condecending, I don't know your level of experience, so please don't take offence!)

One you are using either of the above utilities, it is easy enough to go to the MySQL section (under the Servers section in Webmin) where you can create the database and manage its users and their access rights.

Also check if your application or script comes with an *.sql file to create your tables, if you do, then create the database, assign username and privileges and then create your tables using the sql file provided:

   mysql -uusername -ppassword database < database.sql

Where username is the name you defined, password is the password assigned and database is the database you created, database.sql is the provided sql text file for creation of the tables. Note also that there is no space between the -u and username, -p and password.

Hope this helps

regards
Mahmood