http://dev.mysql.com/doc/refman/5.0/en/macosx-installation.html
In the terminal
$ cd /usr/local/mysql
this will move to the mysql folder.
First time I tried to run
$ mysql
I got an error message:
"command not found"
I had to alter the PATH by typing this:
$ export PATH=${PATH}:/usr/local/mysql/bin
This worked but I don't think it's permanent. I probably need to add it to my .bash shell
Info from here:
http://stackoverflow.com/questions/10577374/mysql-command-not-found
I get a prompt like this:
mysql>
This is good!
I have used the command
CREATE USER
and created brennanp as a user and given myself a password.
Then to connect to the server as brennanp:
$ mysql -u brennanp -p
I don't seem to have the correct permissions as brennanp so I am connecting to the server as root again.
To do this:
$ mysql -u root -p
This asks for a password which I leave blank.
NOW following a Youtube tutorial
KEY POINT: SQL commands must be completed with a semi colon!!!
So to show the databases:
mysql> show databases;
This works and gives a useful output.
Now
mysql> create database userlogin;
This works.
NOW: go into that database
mysql> use userlogin;
Every database is made up of tables
Find out about the tables:
mysql> show tables;
To create a table, use the create table command.
This is a bit complex because you have to add lots of parameters but it's not too challenging to understand.
I added a table.
mysql> create table user(parameters...)
Then
mysql> show tables;
mysql> describe user;
to insert data:
mysql> insert into user(username, passwd, email) values('java', 'javanet', javac@gmail.com');
then
mysql> select * from user;
shows the data!
An interesting and productive few hours!
That's all for now.
No comments:
Post a Comment