Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How do you get Apache and MySQL to work?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
TazG
Guru
Guru


Joined: 22 May 2004
Posts: 320
Location: Canada

PostPosted: Mon Jun 07, 2004 9:56 pm    Post subject: How do you get Apache and MySQL to work? Reply with quote

Hello. I'm a newbie. I have Apache2 and MySQL. Apache is working but MySQL won't. I get an error every time a page tries to use MySQL. mysqld is running. What do I need to do to set this up?
Back to top
View user's profile Send private message
jjasghar
Guru
Guru


Joined: 07 Mar 2004
Posts: 342
Location: $HOME=/usa/tx/austin

PostPosted: Mon Jun 07, 2004 10:07 pm    Post subject: Reply with quote

it took me forever to figure out that. trying to get my phpBB up and running.....

have you created an actual database?

Code:
/usr/bin/mysqladmin -u root create (databasename)

_________________
#include <LinuxUser #324070>
main()
{
printf("and i'm sorry my spellign sucs.");
}
Back to top
View user's profile Send private message
Zannox
n00b
n00b


Joined: 20 Sep 2003
Posts: 42

PostPosted: Tue Jun 08, 2004 2:01 am    Post subject: Reply with quote

I'd suggest pick the parts from this topic that applies to what you want to do. Most likely more then you need but it will get you going and should shed some light on how to get it to work as you want it to.
Back to top
View user's profile Send private message
TazG
Guru
Guru


Joined: 22 May 2004
Posts: 320
Location: Canada

PostPosted: Tue Jun 08, 2004 1:47 pm    Post subject: Reply with quote

Whenever I type mysql it says
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)

?!
Back to top
View user's profile Send private message
Nossie
Apprentice
Apprentice


Joined: 19 Apr 2002
Posts: 181

PostPosted: Tue Jun 08, 2004 2:18 pm    Post subject: Reply with quote

Type: man mysql
and read the instructions
Back to top
View user's profile Send private message
Zannox
n00b
n00b


Joined: 20 Sep 2003
Posts: 42

PostPosted: Tue Jun 08, 2004 2:50 pm    Post subject: Reply with quote

You can also try looking over this topic. The link is just for the mysql part but the guide does cover Apache as well :)
Back to top
View user's profile Send private message
TazG
Guru
Guru


Joined: 22 May 2004
Posts: 320
Location: Canada

PostPosted: Tue Jun 08, 2004 4:19 pm    Post subject: Reply with quote

Ahh, it won't even let me into mysqladmin, or mysql. I set a password in my.cnf and I type:
mysql -u root -p
and type the password but it says 'Access denied for user: 'root@localhost'
If I try to do anything with mysqladmin it does the same thing. I unmerged and remerged mysql but it didn't help.

Apache is working fine, it just can't use MySQL.
Back to top
View user's profile Send private message
jkt
Retired Dev
Retired Dev


Joined: 06 Feb 2004
Posts: 1250
Location: Prague, Czech republic, EU

PostPosted: Tue Jun 08, 2004 4:30 pm    Post subject: Reply with quote

"mysql password" (probably you meant password for root in mysql) isn't set in my.cnf, but in mysql.user table, default is afaik empty password, so:
a) ssh to your mysqld box (skip if you're running mysql on your local computer
b) `mysql -u root`
Back to top
View user's profile Send private message
TazG
Guru
Guru


Joined: 22 May 2004
Posts: 320
Location: Canada

PostPosted: Tue Jun 08, 2004 5:28 pm    Post subject: Reply with quote

The same thing still happens with no password.
Back to top
View user's profile Send private message
jkt
Retired Dev
Retired Dev


Joined: 06 Feb 2004
Posts: 1250
Location: Prague, Czech republic, EU

PostPosted: Tue Jun 08, 2004 5:32 pm    Post subject: Reply with quote

`/usr/sbin/mysql_install_db`?
Back to top
View user's profile Send private message
TazG
Guru
Guru


Joined: 22 May 2004
Posts: 320
Location: Canada

PostPosted: Tue Jun 08, 2004 8:45 pm    Post subject: Reply with quote

I did that, there didn't seem to be any problem with it.
Back to top
View user's profile Send private message
jkt
Retired Dev
Retired Dev


Joined: 06 Feb 2004
Posts: 1250
Location: Prague, Czech republic, EU

PostPosted: Wed Jun 09, 2004 6:33 am    Post subject: Reply with quote

well, quick and dirty fix should be to unmerge mysql, wipe out your databases (don't know exactly where are they located, look at mysql ebuild) and then re-emerge mysql. and tell us what does it say.
Back to top
View user's profile Send private message
TazG
Guru
Guru


Joined: 22 May 2004
Posts: 320
Location: Canada

PostPosted: Fri Jun 11, 2004 2:50 am    Post subject: Reply with quote

Well that worked, sort of. I can get into mysql now but I still get errors on my pages. This is what I did:


mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> grant all on *.* to web@localhost identified by '$password';
Query OK, 0 rows affected (0.04 sec)


Then I restarted mysql and apache. I go to http://localhost and get this:

Access denied for user: 'web@localhost' (Using password: YES)
Back to top
View user's profile Send private message
Zannox
n00b
n00b


Joined: 20 Sep 2003
Posts: 42

PostPosted: Fri Jun 11, 2004 4:04 am    Post subject: Reply with quote

How are you using apache to interface with mysql? PHP?
Back to top
View user's profile Send private message
TazG
Guru
Guru


Joined: 22 May 2004
Posts: 320
Location: Canada

PostPosted: Fri Jun 11, 2004 12:53 pm    Post subject: Reply with quote

Yes, PHP. The error is coming from this line:
$link = mysql_pconnect("localhost",$user,$pass);
Back to top
View user's profile Send private message
Banzai_san
n00b
n00b


Joined: 02 May 2003
Posts: 50

PostPosted: Fri Jun 11, 2004 1:52 pm    Post subject: Reply with quote

I had problem with mysql_connect() when trying to access mysql through php. Now Im able to access mysql date from php.

what I did was I reemerged mod_php again ie
#USE="apache2 mysql" emerge mod_php

stop apache2 & mysql
#/etc/init.d/mysql stop
#/etc/init.d/apache2 stop

restart apache2 & mysql
#/etc/init.d/mysql start
#/etc/init.d/apache2 start

That was all that I did.
Back to top
View user's profile Send private message
jkt
Retired Dev
Retired Dev


Joined: 06 Feb 2004
Posts: 1250
Location: Prague, Czech republic, EU

PostPosted: Fri Jun 11, 2004 3:38 pm    Post subject: Reply with quote

please, do
Code:

SELECT * from mysql.user
Back to top
View user's profile Send private message
TazG
Guru
Guru


Joined: 22 May 2004
Posts: 320
Location: Canada

PostPosted: Fri Jun 11, 2004 6:12 pm    Post subject: Reply with quote

I tried remerging php, and that command, and it still won't work!
Back to top
View user's profile Send private message
Mr_Maniac
Guru
Guru


Joined: 10 Jun 2004
Posts: 546

PostPosted: Fri Jun 11, 2004 8:47 pm    Post subject: Reply with quote

Hmm... Try if

Quote:
grant all on *.* to web@'%' identified by '$password';

works...
_________________
AMD Ryzen 5900X
64 GB DDR4 RAM
GeForce RTX 3080
Gentoo Linux (most recent stable kernel - amd64)
Windows 11 x64
Back to top
View user's profile Send private message
Zannox
n00b
n00b


Joined: 20 Sep 2003
Posts: 42

PostPosted: Fri Jun 11, 2004 9:30 pm    Post subject: Reply with quote

TazG wrote:
Yes, PHP. The error is coming from this line:
$link = mysql_pconnect("localhost",$user,$pass);


Look in that same file, you should find something similar to

$user = "bla";
$pass = "blabla";

make sure that you change bla & blabla to a working user and password. For testing puroses ONLY you can use

$user = "root";
$pass = "rootpassword_to_mysql_database";

You can also stop mysql and emerge -e mysql, then delete /var/lib/mysql/* (to remove all the databases). Emerge mysql again and this time pay attention and note what you set the root user to and the password. Once that is done and you can login using mysqladmin to the mysql database, use the instructions already posted to create the database the Apache will be using. Also remembering to create a user "web" and set it's password and permissions to that database.

Hope this helps.
Back to top
View user's profile Send private message
TazG
Guru
Guru


Joined: 22 May 2004
Posts: 320
Location: Canada

PostPosted: Fri Jun 11, 2004 10:39 pm    Post subject: Reply with quote

Well none of that seems to be working but I fixed it myself:
I had this working before in Windows (with the same pages)... so I copied the files that used to be in C:\mysql to /var/lib/mysql. Now everything's working perfect. Why didn't I do that in the first place?
Back to top
View user's profile Send private message
Zannox
n00b
n00b


Joined: 20 Sep 2003
Posts: 42

PostPosted: Fri Jun 11, 2004 11:15 pm    Post subject: Reply with quote

I'd have to agree with Mr_Manic, it was most likely permssion errors, on the database the web page needed.

For example, if you copied JUST the database over from your windows machine, and did not create a web user within mysql, it would fail. If you created a web user within mysql, and didn't grant it proper permissions on the database it was accessing, it would fail.

I am a bit surprised that just coping the files from the windows box fixed the problem. Just goes to show you the flexibility of mysql :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum