玩VPS的,都应该知道SSH的强大,现在不少虚拟主机也是有SSH权限给你。那么如何快速添加多个MySQL用户及数据库,通过控制面板的便捷操作,依然是得一步步操作,总感觉比较繁琐,进SSH,登录Mysql,添加数据库,给它添加对应的用户并给予权限,一条一条命令地敲更觉费劲。那么看看冰古童学介绍的快速添加大法吧,灰常的强大实用且省时省力。下面内容转自:
http://bingu.net/660/create-multiple-mysql-users-and-databases/
快速添加多个MySQL用户及数据库:
- 用vi新建一个文档:
# vi addusers.txt - 在其中输入:
create database 数据库名称; grant all privileges on 数据库名称.* to 数据库用户名@localhost identified by '密码'; flush privileges;多个用户及数据库,只要重复上面的代码就可以了,例如:
create database 数据库名称1; grant all privileges on 数据库名称1.* to 数据库用户名1@localhost identified by '密码1'; flush privileges; create database 数据库名称2; grant all privileges on 数据库名称2.* to 数据库用户名2@localhost identified by '密码2'; flush privileges; create database 数据库名称3; grant all privileges on 数据库名称3.* to 数据库用户名3@localhost identified by '密码3'; flush privileges; - 保存退出vi
- 输入下列命令:
# /usr/local/mysql/bin/mysql -uroot -p用户root的密码 < addusers.txt - OK,到这里如果顺利执行并没有错误输出的话,就已经完成添加多个用户及数据库的任务了





