Mysql 为应用数据库创建新用户

假如我们再使用mantis bug tool来管理项目bug。那我们需要为为其在mysql中建立一个专属数据库bugtracker。

以下步骤是需要做的:

1.创建bugtracker数据库供mantis来使用,here we go! simplely type in these code:

mysql>mysql -uroot -proot

mysql>create database bugtracker default charset utf8 COLLATE utf8_unicode_ci;

如果你不太明白后面彩色文字的意思,请访问 http://dev.mysql.com/doc/refman/5.0/en/create-database.html

to make a full understanding~!

 

2.创建bugtracker的用户mantis(Suppose you'v already been logged in with root user)

mysql>create user mantis identified by 'report';

如果你的mantis和mysql是在同一个地方,msyql will treat mantis as localhost user, 所以,可以这样来给刚创建的用户赋予权限

mysql>grant all privileges on bugtracker.* to mantis@localhost;

如果你的mantis和mysql在不同的地方(机器),I know u can figure out ~! suppose your ip is '10.78.1.23'

mysql>greant all privileges on bugtracker.* to [email protected];

这样可以使得10.78.1.23(may be a use in LAN)连接到bugtracker数据库,we 'll just say 'NO' to others~!

 

other usefull commands in mysql:

连接:Connection remote

cmd>mysql -h 10.78.1.23 -umantis -preport

查看:Databases & Tables & Fields

mysql>show databases;

mysql>use bugtracker; show tables;

mysql>desc mantis_bug_table;

导入脚本:Import Scripts from local file-system

cmd>mysql -umantis -preport [database]< /home/superman/script/mantis-mysql.sql

'[database]' is required only when we only create tables in our scripts.

another way

mysql>source c:/scripts/myscript.sql

 

导出:backup your database   

cmd>mysqldump -umantis -preport bugtracker > /home/superman/backup/mantis.sql

 

 

 

你可能感兴趣的:(mysql)