0% found this document useful (0 votes)
156 views

Warning: Mysqli - Connect : (HY000/1049) : Unknown Database in Mac Terminal Only

Uploaded by

blessing
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
156 views

Warning: Mysqli - Connect : (HY000/1049) : Unknown Database in Mac Terminal Only

Uploaded by

blessing
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Stack Overflow

1. About
2. Products
3. For Teams

1. Log in  Sign up

2.
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and
our Terms of Service.

1. Home
2.
1. PUBLIC
2. Stack Overflow
3. Tags
4. Users
5. FIND A JOB
6. Jobs
7. Companies
3.
1. TEAMS

What’s this?

2.
Free 30 Day Trial

Warning: mysqli_connect():
(HY000/1049): Unknown database in mac
terminal only
Ask Question
Asked 3 years, 1 month ago
Active 6 months ago
Viewed 28k times
4
2
in mac i want to create cronjob but when i run the php file with database i am getting error in
terminal.

Warning: mysqli_connect(): (HY000/1049): Unknown database


And In the browser run perfect.
phpmysqlapachexampp

share  improve this question  follow 


edited Mar 13 '19 at 12:42
asked Aug 31 '17 at 10:57
Maulik Patel
49411 gold badge66 silver badges1919 bronze badges
add a comment
6 Answers

Active OldestVotes

0
Is your PHP environment the same as your browsers PHP? command line php.ini can differ from,
for example, your XAMP or other installed webserver

I would recommend checking this first

for me this did the trick

edit your .bash_profile file like

export PATH=/Applications/MAMP/bin/php/php7.1.1/bin:$PATH
edit the path to your PHP bin from your XAMP
share  improve this answer  follow 
edited Aug 31 '17 at 11:11
answered Aug 31 '17 at 11:04

dingezzz
4688 bronze badges
add a comment
11
check your port that mysql run . in many cases mysql run in port 3306 but in my mysql it run in
port 3308 and I add this:

$conn = new mysqli("localhost", "root", "", "myDB","3308");


share  improve this answer  follow 
answered Feb 6 at 6:02

kamyar
11111 silver badge44 bronze badges
add a comment
1
I had a similar problem. My code was like this:

$conn=mysqli_connect($servername,$username,$password,$dB) or die("connection failed");


echo "connection success";
Problem: I did not indicate the port number. Solution: I just included the port number, like below:

$conn=mysqli_connect($servername,$username,$password,$db,"3308") or die("connection failed");


echo "connection success";
share  improve this answer  follow 
edited Mar 8 at 11:18

Hayden Eastwood
78511 gold badge88 silver badges1616 bronze badges
answered Mar 8 at 10:18

Mabro DoubleC
1111 bronze badge
add a comment
0
In my case I got similar error

Warning: mysqli_connect(): (HY000/1049): Unknown database 'login.db' in


D:\xampp\htdocs\login\functions\db.php on line 2 so i change [$con=mysqli_connect('localhost',
'root', '', 'login.db');] into [$con=mysqli_connect('localhost', 'root', '', 'login');]
Ii changed 'login.db' to 'login' and error disappear
share  improve this answer  follow 
edited Sep 25 '18 at 6:19

Mike
3,27744 gold badges1313 silver badges3030 bronze badges
answered Sep 25 '18 at 5:50

CoderSoup
111 bronze badge
add a comment
0
If you have this code:

$conn = new mysqli("localhost", "root", "", "myDB");


Try with creating new database called myDB in localhost/phpmyadmin.
share  improve this answer  follow 
edited Mar 13 '19 at 12:23
answered Mar 13 '19 at 11:53
Marko Perendio
6111 silver badge33 bronze badges
add a comment
-1
For me, the problem was the "Port number" (on Step 3 of OpenCart 3.0.3.2 installation) which
was set as 3306 but in MySQL, it was showing as 3308 so I just changed the same and all went
good.

enter image description here


share  improve this answer  follow 
edited Feb 25 at 15:26

Mujahid Bhoraniya
1
answered Feb 20 at 14:02

user2811
1
add a comment
Highly active question. Earn 10 reputation in order to answer this question. The reputation requirement helps
protect this question from spam and non-answer activity.
Not the answer you're looking for? Browse other questions tagged php mysql apache xampp or ask
your own question.
The Overflow Blog
 Podcast 281: The story behind Stack Overflow in Russian
 Failing over without falling over
Featured on Meta
 When is a closeable question also a “very low quality” question?
Remote jobs

Front-End Developer (Remote)


WallethubNo office location
$25K - $65KREMOTE
cssjavascript

Frontend Architect (m/f/d)


SimScaleMünchen, Germany
REMOTE
htmljavascript

Software Engineer III (Anti-Harassment Tools)


Wikimedia Foundation, Inc.No office location
REMOTE
phpjavascript

Junior Data & Growth Engineer


HeySummitEdinburgh, UK
£28K - £32KREMOTE
htmlcss

WordPress Support Engineer


WebDevStudiosNo office location
REMOTE
phpjavascript

Shopify Developer
Tako AgencyNo office location
$55K - $73KREMOTE
htmljavascript

Senior Frontend Software Engineer, JavaScript (Remote)


AutomatticNo office location
REMOTE
phpjavascript

Full-Stack Engineer
Octane AINo office location
REMOTE
javascriptpython
View more jobs on Stack Overflow

Linked

0
How do I resolve this problem? "Warning: mysqli_connect(): (HY000/1049):

Related

1775
How do I get PHP errors to display?

831
How to fix “Headers already sent” error in PHP

1159
Reference - What does this error mean in PHP?

2154
How do I import an SQL file using the command line in MySQL?

49
Warning: mysqli_connect(): (HY000/2002): No such file or directory

3
SQLSTATE[HY000] [1049] Unknown database - Database created, not functioning

0
How do I resolve this problem? "Warning: mysqli_connect(): (HY000/1049):

Hot Network Questions


 Print 2nd line in text file
 Do filtered colimits commute with finite limits in the category of pointed sets?
 What’s the difference between 二五 and 二十五?
 One tuba for everything: CC or F?
 Why is std::pair from anonymous object copying that object instead of moving?
 When we calculate mean and variance, do we assume data are normally distributed?
 Why is there no rule allowing a player to claim a draw in lonely king endgames?
 Can humming a bar of music considered as copyright infringement?
 Which theoretical propulsion system has the highest specific impulse?
more hot questions

 Question feed
https://stack

STACK OVERFLOW
 Questions
 Jobs
 Developer Jobs Directory
 Salary Calculator
 Help
 Mobile
 Disable Responsiveness
PRODUCTS
 Teams
 Talent
 Advertising
 Enterprise
COMPANY
 About
 Press
 Work Here
 Legal
 Privacy Policy
 Contact Us
STACK EXCHANGE
NETWORK
 Technology
 Life / Arts
 Culture / Recreation
 Science
 Other
 Blog
 Facebook
 Twitter
 LinkedIn
 Instagram

site design / logo © 2020 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2020.10.26.37891

You might also like