简体   繁体   English

使用php在mysql中创建数据库

[英]Creating database in mysql using php

Can I create database using php code for free hosted/domain plans. 我可以使用php代码为免费的托管/域计划创建数据库吗? (Hostinger). (Hostinger)。

If so what to write in $db_name 如果是这样,在$db_name写什么

$db_name = "profile"; OR $db_name = " cpannel username_profile"; $db_name = " cpannel username_profile";

For CREATE DATABASE $db_name 对于CREATE DATABASE $db_name

I tried but it get connected. 我试过了,但是连接了。 At the time creating database it says access denied. 在创建数据库时,它说访问被拒绝。

Could not create database: Access denied for user 'user'@'192.168.0.%' to database 'TUTORIALS'

from the error message, it looks like your user 'user' doesn't have privileges to create tables. 从错误消息中,您的用户“用户”似乎没有创建表的权限。 have you granted him privileges to do that? 您是否授予他这样做的特权?

you didn't mention a database, but to grant most privileges to a user, you could do it like this in mysql: 您没有提到数据库,但是要向用户授予大多数特权,您可以在mysql中这样做:

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX ON *.* TO 'user'@'%'

hope this helps. 希望这可以帮助。

If you are using free domains, they will not allow you to create the database with PHP as giving permission for that may result in deletion/addition of databases from other users too. 如果您使用的是免费域,则它们将不允许您使用PHP创建数据库,因为授予该权限可能会导致其他用户删除/添加数据库。 For reference visit: https://forum.infinityfree.net/discussion/2158/access-denied#latest an answer by an admin of one of the free database provider! 作为参考,请访问: https : //forum.infinityfree.net/discussion/2158/access-denied#latest由免费数据库提供商之一的管理员提供的答案!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM