Thursday, August 7, 2008

MySql - tut

linux~

1) Start after a fresh install:

#> mysql -u root

2) Set the password for first time:

From inside SQL:

mysql> set password for 'root'@'localhost' = password ('test')

From outside SQL:

#> mysqladmin -u root password test1

3) If password is set, to change password:

#> mysqladmin -u root -ptest1 password test2

4) See if mysql is running:

#> ps -ef | grep mysqld

5) Starting and Stopping mySQL:

Starting:

#> ./etc/init.d/mysql start

Stop:

#> ./usr/bin/mysqladmin -u root -p shutdown

6) Adding a user to Mysql Db

mysql> use mysql;

mysql> insert into user (host, user, password, select_priv, insert_priv, update_priv) values ('localhost', 'guest', password('guest123'), 'Y', 'Y', 'Y');

mysql>flush privileges;

mysql> select host, user, password from user where user = 'guest';

7) creating a database call tutorials:

mysql> create database tutorials

8) view values in the table

SELECT * FROM table_name

No comments: