Back | Reverse | Quick Reply | Post Reply |

MySQL Help!
Link | by cha on 2008-03-27 01:24:30
I just started learning web programming in the college. and my teacher have told me whatever I need for the class and one of them is about MySQL. I wanted to prepare anything so I download it. But I don't know what to do with it. anyone can help me?

hi, be my friend

Re: MySQL Help!
Link | by × on 2008-03-27 01:57:21
er... cha-san,if you are just joining web programming, mySQL is not too important, but MySQL database, after being installed, can be used by everyone without using username and password. That's why you should activate the password for root and delete the anonym user first. Users and their privileges can be set in grant tables on MySQL.

tableaccess
user
db
host
tables_priv
colums_priv
global
database
database
table
column


and you can give password for root by using this command:

UPDATE user SET password=password ('xxxxxxxxxx')
WHERE user='root';


To check the result, use this command:

SELECT user, password, host FROM user; [ENTER]

userpasswordhost
root
root
6332018e3b069c29
6332018e3b069c29
localhost
build
localhost
build


Then you can make a new user by using this command:

GRANT ALL PRIVILEGES ON *.* TO admin@localhost
IDENTIFIED BY 'password_name' WITH GRANT OPTION;


This command is used to make a new user named admin with a privilege as administrator. This is shown by GRANT ALL PRIVILEGES that means the user admin can access all database in the server (shown by ON *.*) as long as the access is done in localhost. WITH GRANT OPTION give privileges to admin to give privileges to another user.

While to make an ordinary user (for example the username is kisenosky), you can use this command:

GRANT USAGE ON *.* TO kisenosky@localhost
IDENTIFIEAD BY 'password_name';


Now, you can also delete user's privileges by using REVOKE. This command doesn't mean to delete a user, but only the privileges. So, the user still can login to MySQL with the password since the user's data is still on grant tables user.

To delete the privileges of SELECT and INSERT of the user kisenosky, you can use this command:

REVOKE SELECT, INSERT on kisenoskydb.*
FROM kisenosky@localhost;


While to delete ALL privileges, use this command:

REVOKE ALL PRIVILEGES on kisenoskydb.*
FROM kisenosky@localhost;


Notes:
- INSERT - add record on table
- SELECT - show the data of table
And there are some others user privileges in MySQL.

To delete a user permanently, use this command:

DELETE FROM user WHERE user=kisenosky;

I think that's what usually done at first in MySQL... then you can start making your database...

Re: MySQL Help!
Link | by Atsuku(binku) on 2008-04-01 08:11:17
Yeah3x, now i know why there's only 1 replies, wkwkwk.
By da way, cha-san, if u has learn da first important step from kiseno-san, continue to study DDL, DML,...(sorry i only give nothing >.<). Then you are ready to use >>XAMPP<< with effectively, efficiently. Remember, it's much more wisely if u own da main framework of mysql first before u use it(xampp)^^.

Re: MySQL Help!
Link | by × on 2008-04-01 20:33:16
what do you mean by "now i know why there's only 1 replies" huh?

anyway... I think it's too early to learn MySQL if you just started the class. MySQL would be useful when you use PHP. be good at HTML first!

Re: MySQL Help!
Link | by Atsuku(binku) on 2008-04-02 00:03:01
ew, i mean u have made an excellent and weightfull replies so i thunk other people doesn't have to add more statement or knowledge. [I'm praising you.... >.<]
Yeah of course, HTML is always da first, but u doesn't have to study css just to use php, right? ^^

Re: MySQL Help!
Link | by cha on 2008-04-02 23:28:16
Mr Kiseno, Binku was right. your reply is wonderful! you must be a web programmer or a lecturer of web programming! >.<

i'm a bit confused about MySQL, but I understand few of your explanation. I save it as reference.
so, MySQL is used to make a database? btw... How can I make a database in MySQL?

hi, be my friend

Re: MySQL Help!
Link | by × on 2008-04-03 22:38:55 (edited 2008-04-03 23:22:48)
@ Binku-san: CSS is important. we use CSS for DHTML!

@ Cha-san:
Before I answer your question, I want you to know that:

I'm A GIRL! I'm still 16!
So... DON'T CALL ME "Mr. Kiseno"! Do you think I'm a 40 y/o GUY, huh?

Call me "Kiseno-CHAN" or just "Kiseno"!

Remember it or I will never help you again!
(well... I'm just kidding... but please don't call me "Mr"!)

Okay... about making database in MySQL... it’s kinda hard for me to explain it.
So, I’ll give a simplest basic example.
If you have ever use MS Access or another program for making database, it will be easier for you to understand.
But first of all, you have to login with the username you made.
Open CLI (Command Line Interface) MySQL by using this command (in your OS shell):

mysql -u [username] -p

The [username] is the username you have made at the first time (look at my previous post!).
If it needs any password, MySQL will give you promt to enter password.
If this matter is finished, then you will see this prompt:

mysql>

Next, let's start dreaming!
Assume that you are Uzumaki Naruto! (You must know Naruto, eh? You MUST know him!)
Hiruka-sensei just devided your class into some teams.
Your team-mates are Sasuke and Sakura.
Since you are better than Sasuke in technology, you want to show him that you can make a database of all ninja team in Konoha named konoha_gakure. And the personal data of your team members is saved in a table named wearefightingdreamer in the database. (er... I think this is too much, but it's okay! let's continue Kiseno's imagination!)
So, use this command:

CREATE DATABASE konoha_gakure;
USE konoha_gakure;


The first line is used to create a database named konoha_gakure in MySQL, while the second line is a command to CLI MySQL to use the database konoha_gakure. Now, to create a the table wearefightingdreamer, use this command:

CREATE TABLE wearefightingdreamer (
CODE INT(11) NOT NULL AUTO_INCREMENT,
NAME VARCHAR(50) NOT NULL,
LEVEL SMALLINT(3) NOT NULL DEFAULT 0,
EMAIL VARCHAR(50) NOT NULL,
HOBBY VARCHAR(50) NOT NULL,
PRIMARY KEY (CODE)
);


And then, if you are not sure, you can check whether the table has been created or not, use this command (still in CLI MySQL):

DESCRIBE wearefightingdreamer;

If you make no mistakes in making the table, CLI MySQL will give you this result:

FieldTypeNullKeyDefaultExtra
CODE
NAME
LEVEL
EMAIL
HOBBY
int(11)
varchar(50)
smallint(3)
varchar(50)
varchar(50)
PRINULL

0
auto_increment

5 rows in set (x.xx sec)

VARCHAR, INT, SMALLINT are data's variables.
Once again I say, if you have learn MS Access or any program for database, you must know what variables are, and what is primary key.
And AUTO_INCREMENT is used to make an ordered data automatically so the primary keys are always unique.
To make MySQL fill the data automatically, in INSERT we use Null (like in the command below).
Now, try to insert 2 records into the table:

INSERT INTO wearefightingdreamer VALUES (
Null,'Uzumaki Naruto',156,'phantom_renagade@convenience_store.at','exchanging medaparts and robattling');

INSERT INTO wearefightingdreamer VALUES (
Null, 'Haruno Sakura',1,'ugly_girl@jungle_is_my_home.de','being rejected by guys');

INSERT INTO wearefightingdreamer VALUES (
Null, 'Uchiha Sasuke',999,'oh_my_god_i_am_so_handsome@host_club.fr','counting money');


You can check the result by using this command:

SELECT * FROM wearefightingdreamer G

The command is used to pick all data from table wearefightingdreamer.
You can select just few columns by changing * into the columns name seperated by comma (,).
For example NAME, LEVEL.
And here, I use G to end the command SELECT (a command is commonly ended by semicolon), so the data will be displayed vertically, not in a table.
The result is about like this:

********************** 1. row *********************

CODE: 1
NAME: Uzumaki Naruto
LEVEL: 156
EMAIL: phantom_renagade@convenience_store.at
HOBBY: exchanging medaparts and robattling

********************** 2. row *********************

CODE: 2
NAME: Haruno Sakura
LEVEL: 1
EMAIL: ugly_girl@jungle_is_my_home.de
HOBBY: being rejected by guys

********************** 3. row *********************

CODE: 3
NAME: Uchiha Sasuke
LEVEL: 999
EMAIL: oh_my_god_i_am_so_handsome@host_club.fr
HOBBY: counting money

3 rows in set (x.xx sec)


Yup! that's it! Then you can also connect your database to PHP, and try some simple functions in PHP!
For example to count the record in your database, to arrange the data in your database into a table, to search a data from your database, etc... etc... (And of course it's displayed in a web page)
Your teacher/lecturer will (and can) explain it all better than me!

*Sighs...* you make my fingers so curly!
Since I have no experience in explaining something well and my English is not so good, maybe this looks a bit confusing. E-he-he-he-he!
That’s just a little explanation I can do.
I just hope this can help you.
Just ask if you have any problems, but I'm not quite sure that I can always help you because I'm still so much very amateur!

Re: MySQL Help!
Link | by on 2008-09-10 08:18:54 (edited 2008-09-18 01:32:34)
This is the only MySQL thread that I've ever seen in the whole forum.
I'll tag along on helping.

At kiseno chan's table "wearefightingdreamer" this is the result of the table

SELECT * FROM wearefightingdreamer;





CODENAMELEVELEMAILHOBBY
1Uzumaki Naruto156phantom_renagade@convenience_store.atexchanging medaparts and robattling
2Haruno Sakura1ugly_girl@jungle_is_my_home.debeing rejected by guys
3Uchiha Sasuke999oh_my_god_i_am_so_handsome@host_club.frcounting money


3 rows in set (x.xx sec)

@ kiseno-chan
Well, they assume gender of the users by seeing their avatar/sig pictures.
And its \G not just G to make the query vertically.

Anyway, there is another way to input the table contents by using one command.
I'll use your command syntax for reference:

I'm not good at explaining like you so I just type what I know. You will notice the function anyway.

***************************************************************

mysql>INSERT INTO wearefightingdreamer VALUES
->(Null,'Uzumaki Naruto',156,'phantom_renagade@convenience_store.at','exchanging medaparts and robattling'),
->(Null,'Haruno Sakura',1,'ugly_girl@jungle_is_my_home.de','being rejected by guys'),
->(Null,'Uchiha Sasuke',999,'oh_my_god_i_am_so_handsome@host_club.fr','counting money');

***************************************************************

This way, you don't need to input the long table name you got there.
*If you already know this then you learned pretty well.

This is basic mysql. I learned something from you.

I'm still learning but this is what I can do in MySQL so far:

-Same as what Kiseno-chan did, making tables/databases
-connect two or more tables
-queries, displaying selected fields from any tables

Oh yes, for mysql starters that uses Linux.
Some mysql needs to be set up by using xampp.
If you download mysql-server, you can just type "mysql" at the start of the root terminal.
You will be connected to mysql automatically.

Follow the road you believe in -->

Re: MySQL Help!
Link | by tomoyo! :3 on 2008-09-17 09:49:11
Wow, most of the basic stuff is covered by kiseno-chan, so I'll just add in a practical advice.

If everything fails, just use phpmyadmin.

XD


Back | Reverse | Quick Reply | Post Reply |

Copyright 2000-2025 Gendou | Terms of Use | Page loaded in 0.0009 seconds at 2025-12-05 16:50:44