Monday, July 20, 2009

MySql

Starting off
As root, you will need to grant privileges to a user - let's call him luser .

As root, start mysql using the command 'mysql'. create a database, let's call it blah:

CREATE DATABASE blah ;

Grant priviliges to the user:

GRANT ALL PRIVILEGES ON blah.* to 'luser'@'%' WITH GRANT OPTION;

Quit out as root using the command: QUIT

Now, in a normal user account, you can connect to it by typing:

mysql blah

You can see what databases you have access to:

SHOW DATABASES;

You can create a table within the database by typing something like:

create table yonk (id integer);

Let's insert a row:

insert into yonk values (26) ;


Then we can see what tables exist in the database:

SHOW TABLES;

and inspect the data we have just entered:

SELECT * FROM yonk;

Users



select User,Host,password from mysql.user;
Setting passwords
mysql -u rootSET PASSWORD FOR root@localhost=PASSWORD('rubberchicken');

No comments: