View Full Version : MySQL w/ Apache
Mario
01-04-2004, 04:01 PM
Ok, I can get the MySQL server runnin... how can I tie this in with Apache (1.3x) and PHP (4.3x) so I can start loading my image gallery software.
DrJones
01-04-2004, 04:30 PM
Ok, I can get the MySQL server runnin... how can I tie this in with Apache (1.3x) and PHP (4.3x) so I can start loading my image gallery software.
Really Apache itself doesn't need to connect with mysql. It's php that does the database connections.
The hard part about getting everything to work is configuring mysql. You can think of mysql as a program that is always running in the backround, that can accept connections. Therefore in order for it to all work, you need to set up a database and make a user.
That part can be tricky. Mysql has a 'root' user, which is different than your unix or windows root user. This user is the one that can add other users, set permissions, create databases and all that stuff.
For windows:
(i've never done it in windows, but here is what it says in that book I told you about)
In win2k or xp, you need to install mysql as a system service. to do this open a command prompt and run the server with the -install option:
C:\mysql\bin> mysqld-nt -install (assuming C:\mysql is where you installed)
That will install it as a service that will be started the next time you reboot. If you want to start it without rebooting, you can do:
C:\> net start mysql
Verify that it is runing by doing Ctrl+alt+del and make sure you see it in the task list and process tab.
That should have it running, so you can connect to the database. Once you can, the first thing you should do is change the password for the root mysql user. to do this you can type:
mysqladmin -u root password "your new password "
To make sure it worked, you should do
mysqladmin -u root reload
if it gives you an access saying it was denied, than your password has taken effect, (which is good) and you need to do
mysqladmin -u root -p status
which will prompt you for the pw, then give you some status about the DB.
That should set up everything you need to get the db up and running.
Note: I'm using the term DB a little awkwardly here. Here is how it works. You have one copy of the mysql program running in the backround. This is sometimes refered to as the 'database', where more correctly it should be called 'database software.' That program can controll many different databases. Each different thing you are using your database software for (which in your case will probably be one) will have a different database. ie if i was running a message board, I might have a database for that, then if I had another database that contained data gathered for a school project or something, I would have a separate database for that one. There is only one copy of the program running, but different databases contained in it.
Data in a database is stored in Tables, so when you just have a blank database, you can't really do anything with it. You need to create tables (like in excel) that hold your data.
To clarify this a bit, go back to the command prompt and type
mysql -u username -p
username should be the mysql user name. Right now it should be root. Again, -p means prompt for pw. This should dump you into the mysql command line.
mysql>
Here you can execute commands that mysql understands. One would be:
mysql> SHOW DATABASES;
This will give you a list of all the databases that mysql currently has. It should show mysql & test right now. mysql is the database that stores all the information about the database software (like what databases there are, what users, passwords and so on, it's kind of cool that it uses itself for that kind of stuff). The other is just a test database you can play around with.
Note: in mysql you tell it your done with the statement by putting a ; at the end of the line.
That should be enough to get you going. I can give you a basic SQL primer if you want.
The thing to remember is that anything can send info to the mysql server. It can be done directly through the mysql command prompt, or from another application. Those commands are just plain text. So in your php ******, if you connected to the database and sent it "SHOW DATABASES;" It would return the names of the databases. You can also give it commands to run querires, add tables, drop (remove) tables, add/remove elements to a table and so on.
Since you are just getting this up and running so other software will use it, I would consult the documentation for that software (I can look at it for you if you want). It has to create it's own database, and tables and all that. Chances are there is a ****** that will do this all for you. You will also probably have to add a user to the database that you will connect to it as, to have access to that db. Some software packages have you manually do this, others do it for you. You have to check the documentation to see what it needs.
Mario
01-04-2004, 04:47 PM
Thanks so much Paul, I owe you some Bawls or something. :D
Google for "phpmyadmin" - a very good place to start w/the basics of mysql management.
Mario
01-04-2004, 09:57 PM
Google for "phpmyadmin" - a very good place to start w/the basics of mysql management.
Yes, I remember using this program when I setup a watercooling site a year ago.
See, I have no experience from the server-side setting things up - like the installation of hte server, PHP, MySQL, etc. All post work was done from the client-side.
I got my image gallery software up tonight... time for new logo and to get all the pics up. I love this home server thing. :king:
DrJones
01-04-2004, 11:04 PM
Yes, I remember using this program when I setup a watercooling site a year ago.
See, I have no experience from the server-side setting things up - like the installation of hte server, PHP, MySQL, etc. All post work was done from the client-side.
I got my image gallery software up tonight... time for new logo and to get all the pics up. I love this home server thing. :king:
No one has expierence until they do it.
vBulletin® v3.7.1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.