I have built an SQL query and sent it to the MySQL Server using a PHP program/script. Everything was working fine and the connection was good until I attempted to CREATE DATABASE. Then I got this error:
Error: Access denied for user ''@'localhost' to database 'petcatalog'
Does anyone know why I am not connecting and how I fix this?
Thanks
P.S.
I know I can use the command prompt to build a database but I would like to complete this project of building a database using php scripts to connect with mysql server.
13 4259
What is the full error message? It'll include something like 'USING PASSWORD yes'.
it also looks like there’s no login name passed.
Atli 5,058
Expert 4TB
Note that you need to have the CREATE privilege for the database before you create it. Meaning that, before you create the database, a user with the GRANT privilege (like root) needs to issue a GRANT command, giving the user you are using in your scripts permission to create the database.
Because of this, you are generally just better of creating the database using the admin user. You are going to have to use it to grant the privileges anyways.
@Dormilich
I read it as "'user'@'localhost'" - woops :P
FULL ERROR MESS.
Database Selected:
Query: CREATE DATABASE Pet_Catalog
Results
Error: Access denied for user ''@'localhost' to database 'pet_catalog'
i am using the admin (root) account.
Can we see the code-in-question, please?
You do not have the variable $root defined (line #20); I believe you mean to use the variable $user (line #14). You should remove that leading space from your $user variable, too.
I should mention that I am very new at this.
what do you mean by the variable $root not being defined, and
using the variable $user?
I am learning as I go...
- $host="localhost";
- $user=" root";
-
$password=" *******";
-
-
if(!empty($_POST['form']))
-
{
-
$cxn = mysqli_connect($localhost,$root,$******,
-
so how do I define this to allow access to the localhost?
I’d go for - $host="localhost";
-
$user="root";
-
$password=" *******";
-
-
if(!empty($_POST['form']))
-
{
-
$cxn = mysqli_connect($localhost,$user,$******,
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Randell D. |
last post by:
Folks,
I use PHP to write my form data to MySQL.
I have a database with about ten tables. I'm trying to fill one table with
some dummy data (its a contact manager table holding names of...
|
by: Andreas Reuleaux |
last post by:
What works for me with mysql 3.23.49 of Debian GNU/Linux (Woody),
does not any more with mysql 3.23.56 of fink (current-stable,
for fink cf. fink.sf.net) - I am not sure, if this problem is caused...
|
by: John |
last post by:
Hello.
I am currently working through a book on Dreamweaver and using PHP. I
am having a little trouble with setting up the database though. I
have php 4.2.3 and MySQL 4.0.20a. I am running...
|
by: Jim Andersen |
last post by:
Hi,
I made a DTS-package and it works when I execute it manually, but when it is
run by the SQL Server Agent, it fails.
I have use the guide to create a maintenance plan. That doesn't work so...
|
by: vincentw56 |
last post by:
This is the first time I have tried this. What we have is a com object the
generates keys. A developer here wrote a .Net wrapper in C# for this com
object. I am trying to call her dll wrapper...
|
by: RichB |
last post by:
Hello,
The .NET application I have just installed at a client web site is throwing
a strange error. At first the applications works without any problems, but
after 10 mins or so Access denied...
|
by: geodev |
last post by:
I have developed a small application using ASP.NET and VB.NET on my
development machine it works great. When I copy across the files manually to
my test machine and create a Virtual Directory all...
|
by: Johan Johansson (Sweden) |
last post by:
I can't connect to our database (seperate database server) from within my
webservice. I cannot understand why.!!!
* I have configured IIS not to allow anonymous access and to use "windows...
|
by: sammyloo |
last post by:
Hi all,
I'm experiencing a problem using ASP.NET web services to access a
different server with SQL Server 2000 database.
And I get the error of the following
Exception Details:...
|
by: ajos |
last post by:
hi frnds,
im trying to convert my servlets database configuration from ms access to mysql database.however im getting some error like no driver found exception.
to verify this error ive...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |