Home >Database >Mysql Tutorial >php普通用户创建数据库失败_MySQL

php普通用户创建数据库失败_MySQL

WBOY
WBOYOriginal
2016-06-01 13:11:521410browse
<?php //open connection$con = mysql_connect("localhost","test","1234");//judge if successsif(!$con){	dir("Unable to connect to mysql" . mysql_error());}//create database name my_db//mysql_query("CREATE DATABASE my_db",$con))if(mysql_query("CREATE DATABASE my_db",$con)){	echo "Database created";}else {	echo "Error creating database: " . mysql_error();}//close connectionmysql_close($con);?>



其中用户test为普通用户,因此无法创建数据库my_db,错误信息为 Access denied for user 'test'@'localhost' to database 'my_db'

把用户改为root就可以正常创建数据库文件了

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn