LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-15-2005, 08:41 AM   #1
ankscorek
Member
 
Registered: Mar 2003
Distribution: Slackware10.2,SUSE,FC,RHL,Vector Linux,WHAX,PHLAK,bt4,ubuntu,debian,aptosid,backtrack,blackbuntu
Posts: 529

Rep: Reputation: 31
probs with connecting to mysql database using php


i started mysql using the foll procedure

cd /etc
# cp my-medium.cnf my.cnf
# cp /usr/share/mysql/mysql.server /etc/rc.d/rc.mysql

# /etc/rc.d/rc.mysql start &

# su - mysql

$ /usr/bin/mysql_install_db

ls -al /var/lib/mysql/

total 44
drwxr-x--- 4 mysql mysql 4096 Feb 21 20:51 ./
drwxr-xr-x 16 root root 4096 Jan 24 2002 ../
-rw------- 1 mysql mysql 30 Feb 21 20:34 .bash_history
-rw-rw---- 1 mysql mysql 73 Feb 21 20:32 jack5-bin.001
-rw-rw---- 1 mysql mysql 73 Feb 21 20:34 jack5-bin.002
-rw-rw---- 1 root root 4872 Feb 21 20:51 jack5-bin.003
-rw-rw---- 1 mysql mysql 48 Feb 21 20:51 jack5-bin.index
-rw-r--r-- 1 mysql root 591 Feb 21 20:34 jack5.err
drwx------ 2 root root 4096 Feb 21 20:51 mysql/
drwx------ 2 root root 4096 Feb 21 20:51 test/

$ /usr/bin/mysqladmin -u root -p password 'new-password'
Enter password:

# /etc/rc.d/rc.mysql start


whenever i try to login using root it says permission denied

i tried logging in using bash as well as using php scripts ...but both times i am getting the same error msg

however i am able to edit and create tables/databases using webmin...but what use if i am unable to connect to my db using php

kindly help!!!!!

IM USING SLACKWARE10.1

Last edited by ankscorek; 08-15-2005 at 08:45 AM.
 
Old 08-15-2005, 09:58 AM   #2
MassDosage
Member
 
Registered: Aug 2005
Location: London, UK
Distribution: Kubuntu
Posts: 75

Rep: Reputation: 15
Have a tried creating a new user for your database and giving them the correct permissions on your tables and then logging in as this user instead of root? This is more secure in the long run anyway as you won't have to put the root password into wherever your PHP script is getting its login information from.

You might end up getting the same error message but it's worth a go?

Also, how exactly are you passing the user name and password through to mysql from bash/PHP? Code snippets might help see if something is going wrong there.
 
Old 08-15-2005, 08:22 PM   #3
ankscorek
Member
 
Registered: Mar 2003
Distribution: Slackware10.2,SUSE,FC,RHL,Vector Linux,WHAX,PHLAK,bt4,ubuntu,debian,aptosid,backtrack,blackbuntu
Posts: 529

Original Poster
Rep: Reputation: 31
here is the snippet......

///////////////////////////////////////////
mysql_connect("127.0.0.1", "root", "pswd")
or die("Could not connect : " . mysql_error());
echo "Connected successfully";
mysql_select_db("teleDir") or die("Could not select database");

/* Performing SQL query */
$query = "SELECT * FROM Clients";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
///////////////////////////////////////////////////////
when i was using fc this script used to work like a charm...........
how do i create a user granting it all the permissions.....
 
Old 08-16-2005, 08:21 AM   #4
MassDosage
Member
 
Registered: Aug 2005
Location: London, UK
Distribution: Kubuntu
Posts: 75

Rep: Reputation: 15
You can create a new user from the mysql shell using the "create user" command which is described in the mysql manual:

http://dev.mysql.com/doc/maxdb/en/48...61/content.htm

You then grant this user permissions on certain tables etc. using the "grant" command:

http://dev.mysql.com/doc/mysql/en/grant.html

If you have a GUI like mysqlcc it can make this easier.

Is that PHP script running on the same host as the mySQL database?

If you try put "localhost" in place of "127.0.0.1" do you get the same error? And if you try the username as "root@localhost" instead of just "root"? You might also want to look inside the "user" table in the "mysql" database to see what username and host combinations there are.
 
Old 08-16-2005, 07:40 PM   #5
ankscorek
Member
 
Registered: Mar 2003
Distribution: Slackware10.2,SUSE,FC,RHL,Vector Linux,WHAX,PHLAK,bt4,ubuntu,debian,aptosid,backtrack,blackbuntu
Posts: 529

Original Poster
Rep: Reputation: 31
i think i have to create a new user granting him all the permissions ...........as i have tried ll possible combinations with this script and this script is a running script.............im going to make a new user and grant ti all the permissions......any other suggestions pl
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Php search mysql database jamesjoy Programming 4 12-02-2005 07:28 AM
connecting to a MySQL database hsa Linux - General 3 09-16-2005 06:34 AM
connecting to MYSQL remote database opsraja Linux - Software 1 02-18-2005 05:52 AM
php won't write in mysql database!! Boby Programming 5 04-26-2004 04:20 PM
Connecting Mysql Database on remote server akamol Programming 4 10-16-2003 11:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:56 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