Totally Noobie Needs Help

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Totally Noobie Needs Help

Postby DamianHart » 29. October 2008 13:03

Hello!

I am trying to learn how to use PHP and MySQL. I try to read through the forums and do Google searches for answers, but nearly everything seems to assume that the reader has considerable knowledge of...all sorts of things. I do not have any such pre-existing knowledge (well, not much anyway), so I need someone to "take me by the hand" and walk me through things step-by-step.

So. I've installed Xampp and it seems to be running. I have written a simple "Hello World" .php page and been able to access it with a browser and it worked. So I'm assuming all is well.

But I really need to shift to MySQL and don't know where to start. So let me ask the first question and--after that gets answered and I get it working--I'll ask #2 and so on. Perhaps it'll turn into a guide that can be used by other novices!

I need to make sure I can "connect" to MySQL server. I've got a teeeeny tiny amount of learning in by sitting in on a Microsoft SQL Server (Express 5) class and when we wanted to issue DDL commands, we opened a command window and typed sqlcmd <command>

What's the equivalent of sqlcmd in MySQL under the Xampp setup?

Thanks for this and all future help.

---Damian
DamianHart
 
Posts: 6
Joined: 29. October 2008 12:51

Postby Wiedmann » 29. October 2008 13:16

What's the equivalent of sqlcmd in MySQL under the Xampp setup?

http://dev.mysql.com/doc/refman/5.0/en/mysql.html
--> \xampp\mysql\bin\mysql.exe

(BTW: This manual knows all about MySQL...)
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby glitzi85 » 29. October 2008 14:36

If you want to connect to MySQL from PHP you should read the PHP Docs: http://de3.php.net/manual/en/book.mysql.php

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Postby DamianHart » 29. October 2008 16:55

Ultimately I will want to connect via PHP, but first I need to make sure that MySQL is working at all.

Thanks for the links and I'll be sure to go through them. The problem is, typically, that usually assumes more knowledge that I have.

So, I read in the one that I can connect with MySQL bY

>>Invoke it from the prompt of your command interpreter as follows: mysql --user=user_name --password=your_password db_name

So I opened up my command window (Vista, btw) and typed that in substituting my username and password...

mysql is an unknown command

Then I noticed the other reply had: \xampp\mysql\bin\mysql.exe

So I used file explorer to try to run it. A window flashed, then closed. I used command window to try to type it and run it.

I got a variety of errors. After much, much experimentation with it I was able to luck onto a string that actually worked by using:

C:\xampp\mysql\bin\mysql.exe --user=<username> --password=<password>

I then typed show databases and it returned an answer so I'm assuming that MySQL is working as well.

So--thanks for pointing me in the right direction.

However, here come the questions:

(1) the line I had to type was pretty long. Is there a way to set a mysql.exe shortcut on the desktop so that I can get the window up and running without all that typing?

(2) when I was fooling around initially, I opened the xampp mysqladministrator window and it asked me for a user name and password which it then put in the my.ini file. However when I used that info in the startup string, it didn't work. Remembering that the default was root / <empty> I tried that and it didn't work. Then I started tinkering and eventually used root as the user and my password as the password. Why did it accept the password I entered, but not the username I entered? Should I try to get it to accept a username other than root...or should I just not bother?

Thanks again!

---Damian
DamianHart
 
Posts: 6
Joined: 29. October 2008 12:51

Postby glitzi85 » 29. October 2008 17:28

DamianHart wrote:(1) the line I had to type was pretty long. Is there a way to set a mysql.exe shortcut on the desktop so that I can get the window up and running without all that typing?

I don't know if this is possible, but you can add the Path of the mysql executable to the PATH-Variable.
Open the Registry Editor. Start -> Run -> regedit.exe
If you want the Path for all users, then you have to do this as Administrator and go to this path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
Otherwise you have to do it with your Useraccount and go to this Path: HKEY_CURRENT_USER\Environment
In first case you have to edit the Key "Path", in second case you have to create this key (String). Then add your Path to the mysql bin folder to this Variable. For example:

C:\xampp\mysql\bin\

After that, you can just open the command line and type mysql without the path.

DamianHart wrote:(2) when I was fooling around initially, I opened the xampp mysqladministrator window and it asked me for a user name and password which it then put in the my.ini file. However when I used that info in the startup string, it didn't work. Remembering that the default was root / <empty> I tried that and it didn't work. Then I started tinkering and eventually used root as the user and my password as the password. Why did it accept the password I entered, but not the username I entered? Should I try to get it to accept a username other than root...or should I just not bother?

Just don't use this tool. It is old and has a lot of bugs. You can use phpMyAdmin instead, or if you want GUI tools you can download the GUI Tools from MySQL: http://dev.mysql.com/downloads/gui-tools/5.0.html

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Postby Wiedmann » 29. October 2008 17:57

Is there a way to set a mysql.exe shortcut on the desktop so that I can get the window up and running without all that typing?

Just make a shortcut. like any other shortcut you made, to this file with this parameters.

Well, with a little bit more Windows experience, you can find tools like "open command prompt here". With this, you can right click a folder in explorer and start a shell directly in this folder. As a result you can just type "mysql -u <username> -p<password>".
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby DamianHart » 29. October 2008 19:42

Wow. Thanks for all the pointers. I'll see if I can get something cooking. Let's move on to my next question.

My goal in learning all this is (of course) to combine PHP and MySQL over the web. To that end, I've set up the Xampp package on a "distant" computer in my house. What I want to do is simulate the experience of do all this work remotely on a different computer...through the network.

I have (what I shall call) "the server" connected to my LAN. Through the "magic" of Windows networking, I can be on my regular computer and can see the files on the server. Using Notepad--or Dreamweaver--I can create .html and .php pages and then use IE and access them. The server processes the .php just fine and serves them back to my browser.

So now the question is: Can I do this with MySQL as well? Can I run the mysql.exe (or the GUI interface if I figure it out) on my computer but have it create / acccess the databases on the server in the other room? If so (and I suspect the answer is 'yes') ... how do I get on the road for doing that?

I've learned a lot already. Thanks!

---Damian
DamianHart
 
Posts: 6
Joined: 29. October 2008 12:51

Postby Wiedmann » 29. October 2008 20:09

Can I run the mysql.exe (or the GUI interface if I figure it out) on my computer but have it create / acccess the databases on the server in the other room?

Sure, that's the reason for the "--host" parameter.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby DamianHart » 29. October 2008 23:41

The whole "host" thing has me baffled at the moment. I've been able--locally--to get it working, so let me ask you this: I've mapped the Xampp directory on the other computer to be drive X on the working computer.

So the path to it is: X:\mysql\bin\mysql.exe but I rather imagine that's not very helpful.

Now when I look at the admin panel I see a field labeled Local Host Name with a name there...let's say it's FOO...

So, how then do I write the connection line to use FOO as the --host? I tried a few different ways, but got "cannot connect" errors.

Thanks for all your patience...

---Damian
DamianHart
 
Posts: 6
Joined: 29. October 2008 12:51

Postby Wiedmann » 29. October 2008 23:50

Code: Select all
Now when I look at the admin panel I see a field labeled Local Host Name with a name there...let's say it's FOO...

What "admin panel"?

So, how then do I write the connection line to use FOO as the --host?

The value for the host parameter is just the computer name or ip of the pc with the running MySQL. e.g. "mysql --host FOO" (if "FOO" is the computer name of that pc)

I tried a few different ways, but got "cannot connect" errors.

But the MySQL server must allow connections from a remote pc for a given user name. That's not true for the user "root". (you can change this with e.g. phpMyAdmin or local with "mysql.exe")
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby DamianHart » 30. October 2008 04:09

But the MySQL server must allow connections from a remote pc for a given user name. That's not true for the user "root". (you can change this with e.g. phpMyAdmin or local with "mysql.exe")


I've tried several variations using root as the user name and continue to get cannot connect messages. You say it must allow connections from a remote PC. And--even though you say I shouldn't need it for root--how do I set up "allow remote connections"?

Thanks,

---Damian
DamianHart
 
Posts: 6
Joined: 29. October 2008 12:51

Postby Sharley » 30. October 2008 06:06

As mentioned before in this thread don't use the WinMySQLAdmin program as it is deprecated and, in XAMPP, is of little use.



Use http://localhost/phpmyadmin/ instead for just about all things MySQL database related - that is until you get familiar with the Command line, if that is what you intend, but the GUI of phpMyAdmin is quite superb and there is not much that you can't do with it that can be done using the command line.

http://localhost will get you to the XAMPP Welcome Page and in the left column there are several demo databases already constructed for you to test that MySQL is functioning.

When you open phpMyAdmin, after entering root with a password if you set one or without if you haven't set one yet, you will see those demo databases ie. CD Collection (cdcol) in the left column and after clicking on one you will be able to see how they are constructed etc.

In htdocs\xampp you will see the associated php files ie. cds.php for the CD Collection.

In the mysql\data\cdcol\ folder there will be the associated database files - but not directly readable as they are binary files, but just as a reference to where things go.

My advise is to have a click around in phpMyAdmin and setup your own database with a user and password for that user to access the database and see how it all comes together.



The root user should never be associated with a database, as root is the super user and should only access at localhost level to administer all things - and should have a password set for obvious security reasons.

Always create a database with a user and a password so that user can only access that particular database (or several related databases of your choosing).

If you want that user to access from outside the localhost loop back address then in phpMyAdmin under Privileges select that user and click on the Edit button at the end of the user line.

Now drill down till you see a box labeled Change Login Information / Copy User

Now look for Host and from the drop box select Any Host which will put this % in the text box next to it.

Leave everything else as is for that user (unless you wish to change anything) then select Go from within this same box.

Your user should now be able to access the designated database from a remote location...
...and in your script you should be able to use a hostname of your choosing as MySQL will now accept connections on that database name and that database user with user password from Any Host.


If you want the root user to access from outside localhost then it is paramount you set a very good password and then follow the above procedure - remember that root user in the wrong hands can destroy all your databases and the data within and can even manipulate the data for their own evil ends, so be very careful with what you do with the root user.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Postby DamianHart » 28. November 2008 18:00

I'm back! School got a bit hairy for a while and I had to stop working on this in order to concentrate on my homework.

But now I've got time for this and here I go.

I accessed localhost/phpmyadmin and it asks me to log in. Nothing seems to work. I've tried using root as a username, my name as a username, the computer's name as a username...and I've used various passwords.

I've gone to the security php page and it gives me the opportunity to change SuperUser root 's password, so I do...and it says success. Then I stop and restart MySQL (everything really), then reload the myphpadmin page....and still cannot get in.

The message it shows is: Cannot log in to the MySQL server.

It may or may not be related, but I also noted in the old WinMySQLadmin program (that I know you don't recommend) that in the MyODBC window, it says "Not Found Driver 3.51 Not Found" Is this related?

Thanks for the help.

---Damian
DamianHart
 
Posts: 6
Joined: 29. October 2008 12:51


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 79 guests