免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1153 | 回复: 0
打印 上一主题 下一主题

Adding new users to MySQL Databases [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-02-19 22:50 |只看该作者 |倒序浏览
Despite lacking a lot of features MySQL is one of the most popular
database servers available for GNU/Linux platforms. Part of the
attraction is that it's much simpler to setup for a shared hosting
system. This small HOWTO shows how to add new users to a MySQL system
and keep their databases seperate from each other.
Many webhosting companies will offer people who signup with
them a single MySQL database for their use. This would allow their
customers to run a single database based application, anything from a
DVD database
to an online
photo gallery
.
If you have a server of your own it makes a lot of sense to
replicate this setup - for each database application you wish to use
create a specific database to hold its data and create a dedicated user
to access it.
This means that if the application is vulnerable to a security problem only the single database is compromised.
Other reasons to create new users are to allow other users to share your database - if you have a
virtual server
for example.
Creating a new database and associated user involves using the mysql client command.
When you install the
mysql-server
package on Debian you will by default end up with a superuser account
setup for the database server root with an empty password.
Hopefully you've changed that afterwards.
If you want to create a new user paul with a database that they have full control over we will run the following commands:
Note that 'mysql>' is the command prompt for the client program mysql, its not something you must type yourself.
#
# Connect to the local database server as user root
# You will be prompted for a password.
#
mysql -h localhost  -u root -p
#
# Now we see the 'mysql>' prompt and we can run
# the following to create a new database for Paul.
#
mysql> create database pauldb;
Query OK, 1 row affected (0.00 sec)
#
# Now we create the user paul and give him full
# permissions on the new database
mysql> grant CREATE,INSERT,DELETE,UPDATE,SELECT on pauldb.* to paul@localhost;
Query OK, 0 rows affected (0.00 sec)
#
# Next we set a password for this new user
#
mysql> set password for paul = password('mysecretpassword');
Query OK, 0 rows affected (0.00 sec)
#
# Cleanup and ext
mysql> flush privileges;
mysql> exit;
Once all this has done you have created a new user with
complete control over the contents of the database pauldb - the user
can create new tables, delete them and generally use the database.
Note that this new user will have no other access to the server, only the dabase that you gave them permissions on.
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/6418/showart_76415.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP