View previous topic :: View next topic |
Author |
Message |
TazG Guru
Joined: 22 May 2004 Posts: 320 Location: Canada
|
Posted: Mon Jun 07, 2004 9:56 pm Post subject: How do you get Apache and MySQL to work? |
|
|
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 |
|
|
jjasghar Guru
Joined: 07 Mar 2004 Posts: 342 Location: $HOME=/usa/tx/austin
|
Posted: Mon Jun 07, 2004 10:07 pm Post subject: |
|
|
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 |
|
|
Zannox n00b
Joined: 20 Sep 2003 Posts: 42
|
Posted: Tue Jun 08, 2004 2:01 am Post subject: |
|
|
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 |
|
|
TazG Guru
Joined: 22 May 2004 Posts: 320 Location: Canada
|
Posted: Tue Jun 08, 2004 1:47 pm Post subject: |
|
|
Whenever I type mysql it says
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
?! |
|
Back to top |
|
|
Nossie Apprentice
Joined: 19 Apr 2002 Posts: 181
|
Posted: Tue Jun 08, 2004 2:18 pm Post subject: |
|
|
Type: man mysql
and read the instructions |
|
Back to top |
|
|
Zannox n00b
Joined: 20 Sep 2003 Posts: 42
|
Posted: Tue Jun 08, 2004 2:50 pm Post subject: |
|
|
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 |
|
|
TazG Guru
Joined: 22 May 2004 Posts: 320 Location: Canada
|
Posted: Tue Jun 08, 2004 4:19 pm Post subject: |
|
|
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 |
|
|
jkt Retired Dev
Joined: 06 Feb 2004 Posts: 1250 Location: Prague, Czech republic, EU
|
Posted: Tue Jun 08, 2004 4:30 pm Post subject: |
|
|
"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 |
|
|
TazG Guru
Joined: 22 May 2004 Posts: 320 Location: Canada
|
Posted: Tue Jun 08, 2004 5:28 pm Post subject: |
|
|
The same thing still happens with no password. |
|
Back to top |
|
|
jkt Retired Dev
Joined: 06 Feb 2004 Posts: 1250 Location: Prague, Czech republic, EU
|
Posted: Tue Jun 08, 2004 5:32 pm Post subject: |
|
|
`/usr/sbin/mysql_install_db`? |
|
Back to top |
|
|
TazG Guru
Joined: 22 May 2004 Posts: 320 Location: Canada
|
Posted: Tue Jun 08, 2004 8:45 pm Post subject: |
|
|
I did that, there didn't seem to be any problem with it. |
|
Back to top |
|
|
jkt Retired Dev
Joined: 06 Feb 2004 Posts: 1250 Location: Prague, Czech republic, EU
|
Posted: Wed Jun 09, 2004 6:33 am Post subject: |
|
|
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 |
|
|
TazG Guru
Joined: 22 May 2004 Posts: 320 Location: Canada
|
Posted: Fri Jun 11, 2004 2:50 am Post subject: |
|
|
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 |
|
|
Zannox n00b
Joined: 20 Sep 2003 Posts: 42
|
Posted: Fri Jun 11, 2004 4:04 am Post subject: |
|
|
How are you using apache to interface with mysql? PHP? |
|
Back to top |
|
|
TazG Guru
Joined: 22 May 2004 Posts: 320 Location: Canada
|
Posted: Fri Jun 11, 2004 12:53 pm Post subject: |
|
|
Yes, PHP. The error is coming from this line:
$link = mysql_pconnect("localhost",$user,$pass); |
|
Back to top |
|
|
Banzai_san n00b
Joined: 02 May 2003 Posts: 50
|
Posted: Fri Jun 11, 2004 1:52 pm Post subject: |
|
|
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 |
|
|
jkt Retired Dev
Joined: 06 Feb 2004 Posts: 1250 Location: Prague, Czech republic, EU
|
Posted: Fri Jun 11, 2004 3:38 pm Post subject: |
|
|
please, do
Code: |
SELECT * from mysql.user
|
|
|
Back to top |
|
|
TazG Guru
Joined: 22 May 2004 Posts: 320 Location: Canada
|
Posted: Fri Jun 11, 2004 6:12 pm Post subject: |
|
|
I tried remerging php, and that command, and it still won't work! |
|
Back to top |
|
|
Mr_Maniac Guru
Joined: 10 Jun 2004 Posts: 546
|
Posted: Fri Jun 11, 2004 8:47 pm Post subject: |
|
|
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 |
|
|
Zannox n00b
Joined: 20 Sep 2003 Posts: 42
|
Posted: Fri Jun 11, 2004 9:30 pm Post subject: |
|
|
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 |
|
|
TazG Guru
Joined: 22 May 2004 Posts: 320 Location: Canada
|
Posted: Fri Jun 11, 2004 10:39 pm Post subject: |
|
|
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 |
|
|
Zannox n00b
Joined: 20 Sep 2003 Posts: 42
|
Posted: Fri Jun 11, 2004 11:15 pm Post subject: |
|
|
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 |
|
|
|