# Help me Start Mysql



## ellias2007 (Feb 3, 2009)

Hi all,
i downloaded Mysql (Version 5.1.30-osx10.5-x86), in order to use it with a Java program and Jdbc ...
After the installation is complete, i Searched the Physical files the installer creates ... i found Nothing ...
Does the installer make Phyisical files?? Hidden files ??Pref Panels?? extentions ?? What and where ??
in other hand, i read that the installer put the programme in the directory :
usr/local...
WHERE is this directory???? i searched All my Mac HD???
Please help me as i am beginner with Mysql...
Thanks


----------



## simbalala (Feb 3, 2009)

It's in /usr/local

There is a pref panel for starting it but I don't remember if that's a separate download.


----------



## ellias2007 (Feb 3, 2009)

Can you please advice me about the Exact location of this directory??
i searched in all my Hard drive for the name usr, it contains only :
MacHD/Developer/SDKs/MacOSX10.5.sdk/*usr*/local
and
MacHD/Developer/SDKs/MacOSX10.4u.sdk/*usr*/local
it is really strange ! 
Many Thanks


----------



## simbalala (Feb 3, 2009)

Just open terminal and type  this:    cd /usr (return)

and you're in /usr

type: cd local and then: ls

and you'll see it.


----------



## ElDiabloConCaca (Feb 3, 2009)

simbala's got it right: you need to use and feel comfortable using the Terminal -- which is the command-line interface to Mac OS X.

Using Mac OS X's Finder to try and find that folder will only lead to frustration.  Ditch the GUI and go commando-style with the command line and Terminal.


----------



## ellias2007 (Feb 5, 2009)

Thanks Simbalala ..
u r right ... may be my question was trivial ... that is because i am not familiar with Unix (and may be i don't want) because i am very familiar with mu Loved OS Classic MacOS, and since MacosX comes i did not try to give a smile to the command line strategie because i get the Bad smell of the Bad MS windows OS when i open command Line interface ... 
well.... now i am in terminal.. i did what you told me Sambalala and i entered local and see inside these three items :
MySQLCOM			mysql
include				mysql-5.0.51a-osx10.5-x86
lib				mysql-5.1.30-osx10.5-x86

hmmmm... how to create a small database now...??See it?? fill it??? where the work willtake place?? via Terminal ?? or others??
Thanks to clear this point.. of link me to a pdf that explains all the stuff??
finally, can i Rate your answer here?? like in other forums to give you points for your usefull answers?
Thanks


----------



## simbalala (Feb 6, 2009)

ellias2007 said:


> Thanks Simbalala ..
> u r right ... may be my question was trivial ... that is because i am not familiar with Unix (and may be i don't want) because i am very familiar with mu Loved OS Classic MacOS, and since MacosX comes i did not try to give a smile to the command line strategy
> 
> hmmmm... how to create a small database now...??See it?? fill it??? where the work willtake place?? via Terminal ?? or others??
> ...


You'll have to earn your spurs. You'll probably want to use php to work with any database you set up.

I suggest finding an open source php project (maybe phpBB) and getting it running on your machine. Then as you work with it, study it and begin to understand it you'll learn more and more about mySQL and php.

It takes time.


----------



## ellias2007 (Feb 6, 2009)

> You'll probably want to use php to work with any database you set up.
> 
> I suggest finding an open source php project (maybe phpBB) and getting it running on your machine. Then as you work with it, study it and begin to understand it you'll learn more and more about mySQL and php.



No... simply i want to Make a small DataBase, and i will access it, edit it, make all queries from a Java-program that will connect to the database via Connector/j .... all other stuffs are clear and i have no problem here .... only making the Mysql database sample so i can start my Java code and test and edit it ....
thanks again


----------



## ElDiabloConCaca (Feb 6, 2009)

mySQL comes with a database for you to play with already -- it's called "test".  It's ready for you to assign user permissions and create tables in it.

You can create tables with simple SQL syntax.  From the command line, log into the mySQL server:

```
$ mysql -u [username] -p
```
Where '$' is the command-line prompt and [username] is your mySQL username (root or whatever).  Enter your password when prompted.

Then, create a table with the SQL syntax:

```
> use test;
> create table "[tablename]" ([col1] [type1] (, [col2] [type2] ...));
```
Where '>' is the mySQL command prompt, [tablename] is the name of the new table you want to create in the database named "test", [col1] is the name of the column you wish to create, [type1] is the type (integer, char(x), etc.) of data associated with that column, and so on and so forth.

I highly recommend downloading the mySQL GUI tools (mySQL Query Browser and mySQL Administrator) from the mysql.com site.  A direct link is here:

http://dev.mysql.com/downloads/gui-tools/5.0.html

Those tools will help you graphically configure your server instead of having to use the command line for basic kinds of things like creating databases/tables, modifying user permissions and viewing the status of your mySQL database server process.


----------



## ellias2007 (Feb 7, 2009)

Dear ElDiabloConCaca,
Let me first Thank you for your Usefull answer,
Second, My problem is simple... i am working in a Java program that i must use to access any database via Jdbc-Connector/J driver .... i know easly load the driver and make what i want in the level of the Java code.... only 2 simple steps make still a problem :
Making the MySql Database, and connect to it ...
Please stay help me doing these 2 steps ....



> From the command line, log into the mySQL server:
> Code:
> $ mysql -u [username] -p



i did, i get :
-bash: $: command not found



> Where [username] is your mySQL username (root or whatever)



here is an ambiguous point .... What is the [username]?? what i must put here??
Assume that My Java program is on my desktop, and i did not make any physical file as Database (unless the "test" initial Databse coming with Mysql), What [username] must be?
and Same question for the "password"....




> Then, create a table with the SQL syntax:
> Code:
> > use test;
> > create table "[tablename]" ([col1] [type1] (, [col2] [type2] ...));
> Where '>' is the mySQL command prompt, [tablename] is the name of the new table you want to create in the database named "test", [col1] is the name of the column you wish to create, [type1] is the type (integer, char(x), etc.) of data associated with that column, and so on and so forth.



These things are very clear for me, as i know well writing a database and making all kind of queries (but from a gui Not Terminal...)



> I highly recommend downloading the mySQL GUI tools (mySQL Query Browser and mySQL Administrator) from the mysql.com site.



i did, i opened MySQL Administrator (and MySQL Query Browser) i get a window with the title "Connect to MySql Instance" and inside it i must fill :
Stored Connection
User Name
Password
...




> Those tools will help you graphically configure your server instead of having to use the command line for basic kinds of things like creating databases/tables, modifying user permissions and viewing the status of your mySQL database server process.



Without Terminal?? Perfect...

Waiting your reply : Thanks Again....


----------



## ElDiabloConCaca (Feb 7, 2009)

ellias2007 said:


> i did, i get :
> -bash: $: command not found


Do not type the '$' character.  As I stated above, that represents the bash command-line prompt.  Type everything after it only.



> here is an ambiguous point .... What is the [username]?? what i must put here??


Like UNIX, mySQL supports multiple users.  When you first set up mySQL, only one user exists: root.  You can create more users with differing permission levels for different purposes.  For example, on a web page that only reads data from the database (and does not write to it), you would create a user that has read-only permissions, then use that user to connect to the database via the web page (php, etc.) to read data.

Put whatever user you wish to use in place of [username].  Likewise for [password].



> i did, i opened MySQL Administrator (and MySQL Query Browser) i get a window with the title "Connect to MySql Instance" and inside it i must fill :
> Stored Connection
> User Name
> Password
> ...


You need to put in the address to your server (localhost or 127.0.0.1 for a local mySQL database), the username you wish to connect with and the password for that username.

"Stored connections" are simply "bookmarks" that you can create so you don't have to type the server/user/pass every time.


----------



## ellias2007 (Feb 8, 2009)

Hi Again,
This is what i wrote in Terminal and what it gave me :
***************
Last login: Sun Feb  8 10:51:00 on ttys000
Unknown-00-1e-c2-04-7d-63:~ ellias2007$ mysql -u [ellias2007] -p
-bash: mysql: command not found
Unknown-00-1e-c2-04-7d-63:~ ellias2007$ cd /usr/local
Unknown-00-1e-c2-04-7d-63:local ellias2007$ ls
MySQLCOM			mysql
include				mysql-5.0.51a-osx10.5-x86
lib				mysql-5.1.30-osx10.5-x86
Unknown-00-1e-c2-04-7d-63:local ellias2007$ mysql -u [ellias2007] -p
-bash: mysql: command not found
Unknown-00-1e-c2-04-7d-63:local ellias2007$ mysql -u [root] -p
-bash: mysql: command not found
Unknown-00-1e-c2-04-7d-63:local ellias2007$ 
***************



in other Hand... i downloaded from the net the free software "Sqleditor", made a small database "MyFirstSqlEditor" and put the Physical file (MyFirstSqlEditor) in my desktop...
i wrote the following Java-code
++++++++++
import java.sql.*;
public class Tesst {
    public static void main(String[] args) {
        try {Class.forName("com.mysql.jdbc.Driver").newInstance();
        System.out.println("it is okey");
        String url = "jdbc:mysql://~/Desktop/MyFirstSqlEditor";
        Connection MyCon = DriverManager.getConnection(url);
        }
        catch (Exception E)
        {System.out.println("Erroor!");
        }
        }
}

and Run it (using NetBeans IDE 6.5)
i get :
run:
it is okey
Erroor!
BUILD SUCCESSFUL (total time: 1 second) 

(i can load the driver but not to connect to the database)



i am sorry ... but i need your help...
Thanks again


----------



## ElDiabloConCaca (Feb 8, 2009)

Don't put "[" and "]" around the names, and add "./" before "mysql," like so:


```
./mysql -u root -p
```
Then, enter the root password when prompted.

Is "ellias2007" your Mac OS X username, or is it a user you have set up in the mySQL database?  The two are mutually exclusive -- just because you have a user account on Mac OS X doesn't mean that user account will work with mySQL.  Your user accounts for OS X are completely different than your user accounts for mySQL.


----------



## ellias2007 (Feb 10, 2009)

> Don't put "[" and "]" around the names, and add "./" before "mysql," like so:
> 
> ./mysql -u root -p




Dear ElDiabloConCaca,

in witch directory i should be when i make the command :
./mysql -u root -p

as you see in the following lines, i tried many positions ....


```
Last login: Tue Feb 10 15:20:26 on ttys000
ellias-a73b0b4c:~ ellias2007$ ./mysql -u root -p         (from Home directory : ~)
-bash: ./mysql: No such file or directory
ellias-a73b0b4c:~ ellias2007$ cd /usr
ellias-a73b0b4c:usr ellias2007$ ./mysql -u root -p        (from directory : usr)
-bash: ./mysql: No such file or directory
ellias-a73b0b4c:usr ellias2007$ cd local
ellias-a73b0b4c:local ellias2007$ ./mysql -u root -p      (from Home directory : local)
-bash: ./mysql: is a directory
ellias-a73b0b4c:local ellias2007$ cd mysql
ellias-a73b0b4c:mysql ellias2007$ ./mysql -u root -p     (from Home directory : mysql)
-bash: ./mysql: No such file or directory
ellias-a73b0b4c:mysql ellias2007$ mysql -u root -p       (without ./)
-bash: mysql: command not found
ellias-a73b0b4c:mysql ellias2007$ -u root -p                (without ./mysql)
-bash: -u: command not found
ellias-a73b0b4c:mysql ellias2007$ ls
COPYING			data			mysql-test
EXCEPTIONS-CLIENT	docs			scripts
INSTALL-BINARY		include			share
README			lib			sql-bench
bin			man			support-files
```




> Is "ellias2007" your Mac OS X username??



"ellias2007" is my Home directory .... (it is /users/ellias2007)


----------



## ellias2007 (Feb 12, 2009)

> I highly recommend downloading the mySQL GUI tools (mySQL Query Browser and mySQL Administrator) from the mysql.com site



Yes ElDiabloConCaca, u r right ... they r graghic tools and it seems that they let us forget the Terminal-command line garbage .... but .. hmmmmm!
i tried the "MySql Query Browser" .. it made many problems :
1) when i right-click on the object browser and make New Schema, write a name for this new shema, and click OK .. NOTHING happens and i can NOT see the New shema in the list in the object Browser! ... i right click again and choose Refresh ... Nothing appears !
2) after i try 2 or 3 times doing that, the software Quit unexp....
3) Is MySql Query Browser able to make a new Database and Design the relation ship between its tables ??? i read ALL its Manual Guide, i found Nothing !
Finally, the mac version does Not contain all what the windows version does!


----------

