SQL   « Smbmount - Mount Windows share folder on Linux or Mac | HOME | 自作サーバ »

 ■ mysql - general

Setup password
# mysql -u root -p 1234

Login
# mysql -u root -p1234
or
# mysql -u root -p
then you are prompted to input password.


Create database
> create database sample;

Show database
> show databases;

Create user & give authority
> grant all privileges on sample.* to user@localhost identified by 'pass';

or you can do this separately.
> create user user_name identified by '1234';
> grant given_rights on database_name.table_name to user_name;

if all priviledges are given, given_rights is 'all'.
if all database and table can be accessed, database_name.table_name can be '*.*'.


Delete user
> drop user user_name;

Check user creation
> exit
# mysql -u user -p


Delete database
>drop database sample;

Check environment
> status


Change charset
Add below in /etc/my.cnf

[client]
default-character-set=sjis

[server]
default-character-set=sjis


and table setup


Change prompt
You can change the word of prompt like below. (normally it is mysql >)
> prompt word_of_prompt>
then prompt word will be changed.
word_of_prompt >

of when you login to mysql, you can indicate with "--prompt=prompt word_of_prompt"

also you can input below to show respectively.
\d : database name
\h : host name
\u : user name

if you want to resume to the default,
> prompt mysql >


mysqladmin
Benefit is you don't have to login to mysql.

Create database
# mysqladmin -u user -ppassword create database_name

Delete database
# mysqladmin -u user -ppassword drop database_name


If you dont want to enter to mysql program, write command like this
# mysql database_name -u user -ppassword -e "command"

投稿者 tomopugh : 2007年05月02日 14:23

Comment

love, pugh

投稿者 pugh : 2007年05月02日 16:40

できた?

投稿者 tomo : 2007年05月03日 11:23

Please comment !




Save the info?


  (Please don't click on "post" twice. It takes time a bit to change to the next screen!!)