开发者

Create table and grant permission to new user

With codeigniter I would like to have something similair to: Codeigniter,create ta开发者_运维技巧bles and users for MySQL

But I need to add new table with new user and password. Like

$this->load->dbforge()

if ($this->dbforge->create_table('my_db'))
{
    echo 'Database created!';
}

and add premission with new user and pass to table: 'my_db' as only reading (SELECT)! If someone can help me with this it should be great!


Have not used CodeIgniter, but I think you can use something like this -

$this->db->query('YOUR QUERY HERE');

http://codeigniter.com/user_guide/database/queries.html

And here it is script example -

CREATE USER 'user1'@'%'; -- specify new account - user name + host name
SET PASSWORD FOR 'user1'@'%' = PASSWORD ('pwd'); -- set password
GRANT SELECT ON TABLE db_name.table_name TO 'user1'@'%'; -- grant SELECT privilege
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜