I am trying to enter data into the joke table. I have copied and pasted both commands as printed. Unfortunately, both commands return a syntax error message:
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'joke INSERT INTO joke SET joketext = "A programmer was found dead in the shower.' at line 3 0.000 sec
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'joke INSERT INTO joke SET joketext = "A programmer was found dead in the shower.' at line 3 0.000 sec
Without looking at the book, should the query really begin with the word ājokeā?
That doesnāt seem right. It should probably begin with āINSERTā.
So, to add a joke to our table, we can use either of these commands:
Copy
INSERT INTO joke SET
joketext = "A programmer was found dead in the shower. The instructions read: lather, rinse, repeat.",
jokedate = "2021-10-29"
// or Copy
INSERT INTO joke
(joketext, jokedate) VALUES (
"A programmer was found dead in the shower. The instructions read: lather, rinse, repeat.",
"2021-10-29")
Thanks for your response. Unfortunately, neither of your strings work; there is no Action Output, but at least this time there is no syntax error message.
I note that both today and yesterday, when I first reported the problem, Docker appears not to be connecting:
'Error response from Daemon: Ports are not available: listen to tcp 0.0.0.0.3306: blind: Only one usage of each socket address (protocol/network address/port) is normally permitted."
Iām not doing anything differently to what I was doing with Docker before I reached this point so I am mystified as to what the problem is. Any advice is much appreciated.
When you started docker today what command did you use to start it?
I used ādocker compose upā. This is what I normally use without problem. I also tried ādocker compose startā with the same result.
It seems that this (connection) problem with docker began only after I installed and configured MySQL. Everything was fine and dandy with Docker up to that point.
I suspect that I may have installed/configured MySQL incorrectly, so wonder if uninstalling MySQL and installing it again would be worth a try?
Iām not sure if author @TomB is around, but he might be able to help out here. I donāt think you should need to install MariaDB yourself, as it is installed in the Docker environemnt you dowloaded in Chapter 1 (but Iām no expert on these things!)
If you have installed MySQL instead of or alongside MySQL Workbench, the default configuration probably has it run in startup unless you chose otherwise during the installation.
MySQL is the database server, and MySQL Workbench is the client. The docker image provided already includes MySQL server. So if you install and run MySQL directly on your computer then the version that runs in Docker will try to run on the same port and fail because the MySQL installation on your computer is already running.
The simple solution is to stop the MySQL service running on startup on your computer so that the port is free for the version you run in Docker.
You donāt need MySQL installed on your computer directly, only MySQL Workbench, MySQL (or more accurately, MariaDB) is provided as a docker image.
Thank you all for your support. I had downloaded and installed a suite of MySQL apps, only one of which was MySQL Workbench, and it appears that other apps were running as TomB suggested. I uninstalled them all except MySQL Workbench.
I have just now successfully inserted the first of the jokes into the joke database and can continue with the process of working through the Novice to Ninja coursebook.
OK, I spoke too soon. I was not able to add the first joke to the database after all. (The fact that even just something appeared in the Action Output made me think I had had success.)
The error message that I am receiving now is:
Error Code: 1364. Field āidā doesnāt have a default value 0.000 sec
Hereās a screen shot to give you a clearer idea: