Hi!
Hope you are doing great.I am getting error while connecting mysql with node, and the error is
{ Error: ER_BAD_DB_ERROR: Unknown database 'dicionary'
at Handshake.Sequence._packetToError (/Users/admin/Documents/dicionario/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Handshake.ErrorPacket (/Users/admin/Documents/dicionario/node_modules/mysql/lib/protocol/sequences/Handshake.js:124:18)
at Protocol._parsePacket (/Users/admin/Documents/dicionario/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/Users/admin/Documents/dicionario/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/Users/admin/Documents/dicionario/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/Users/admin/Documents/dicionario/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (/Users/admin/Documents/dicionario/node_modules/mysql/lib/Connection.js:91:28)
at Socket.<anonymous> (/Users/admin/Documents/dicionario/node_modules/mysql/lib/Connection.js:525:10)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
--------------------
at Protocol._enqueue (/Users/admin/Documents/dicionario/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/Users/admin/Documents/dicionario/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/Users/admin/Documents/dicionario/node_modules/mysql/lib/Connection.js:119:18)
at Object.<anonymous> (/Users/admin/Documents/dicionario/server.js:23:5)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
code: 'ER_BAD_DB_ERROR',
errno: 1049,
sqlMessage: 'Unknown database \'dicionary\'',
sqlState: '42000',
fatal: true }
I am using node version 10.15.0.
Please let me know where i am wrong , i am stuck there and didn't get any success.
Thanks
Hi @Alaa-mansour ! The error ER_BAD_DB_ERROR: Unknown database 'dicionary' is something your MySQL server is returning back, as there is either no table named "dicionary" in your database or the user you're connecting with does not have access to such a table.
I notice that "dicionary" has a typo in it, so perhaps you meant to connect with the database name of "dictionary" ?
Hi @dougwilson yes i have corrected the typo , and the problem is when am creating a database in phpmyadmin mysql can't see it and in reverse when am creating in mysql and phpmyadmin can't see it,
i have alreaddy checked the user privileges.
I mean, either they are connected to different databases or it's different users. Without access to your database I can't really say.
Try running SELECT CURRENT_USER() in both just as a sanity check, for example.
@Alaa-mansour then its obvious you have more than one mySql servers on your machine. I had this issue once.
If you installed XAMPP on your system, it normally installs its own my mySQL server (which phpmyAdmin connects to) even if your system has one already, unless you specifically instruct it not to install its server.
Now it seems your OS already has a mySQL server installed, so anytime the 'mysql' command is executed, it calls the one recognised by the OS, not the phpmyAdmin's mySQL. You could therefore create your 'dicionary' database through terminal or commandline, so it can be found in the system recognised mySQL.
Or you can install mySQL workbench or Navicat IDE to connect to your system recognised mySQL and manage your databases.
You can link up with me if you require any other help www.marcus-hiles.com
Hi @marcus-hiles I believe you responded to the wrong person here. I'm not having the issue described, I am just trying to help OP.
lol @dougwilson , thanks
@marcus-hiles i entered your blog i think the contact page isn't appearing for some reason
Ayte @Alaa-mansour, thanks for notifying me, will update shortly
@dougwilson thank you , i will try to see if this works
@dougwilson i resolved the problem by going to htdoc getinfo and setting the privilege of everyone to read & write ..
really weird how this solved the problem
Hi @Alaa-mansour I'm glad your issue was resolved. it sounds like it was a permissions issue on the MySQL server, most likely.

I also get a similar error when accessing mysql in phpmyadmin. I found a lot of ways but didn't solve it. The same thing, I have no problems on my old computer.
Suddenly discovered that the port of mysql in phpmyadmin installed on my new computer is 3308 by default. After I changed it to 3306, the problem was solved. I'm so happy!!
Most helpful comment
Try running
SELECT CURRENT_USER()in both just as a sanity check, for example.