mysql 6.5 docker run "unknown flag: --character-set-server" - mysql

I tried to run mysql 5.6 from docker like this:
docker run --name mysqlxx -e MYSQL_ROOT_PASSWORD=xxx \
--character-set-server=utf8mb4 \
--collation-server=utf8mb4_unicode_ci \
-d mysql:5.6
but got the following error
unknown flag: --character-set-server
anyone knows what happens? is it a bug of mysql 5.6 Dockerfile?
the image is pulled from https://hub.docker.com/_/mysql

What you have written means that you pass --character-set-server and --collation-server as arguments to docker, and NOT to mysql.
As soon as these flags are related to MySQL, you have to pass them to MySQL service, not docker. Command line for container starts right after image name (mysql:5.6). That will look somehow like:
docker run --name mysqlxx -e MYSQL_ROOT_PASSWORD=xxx -d mysql:5.6 mysql --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
If you can supply them as environment, better use this approach, but you would have to prepend -e for each environment variable. Sorry, I have no idea if MySQL accepts such parameters from environment

as #grapes said, the arguments should be put after image name. below command works.
docker run --name mysqlxx -p 3336:3306 \
-e MYSQL_ROOT_PASSWORD=xxx -d mysql:5.6 \
--character-set-server=utf8mb4 \
--collation-server=utf8mb4_unicode_ci

Related

Docker Container DB dont show up

Hello currently I get in touch with Docker. I am doing their getting started and I ran into a problem which I cant solve and I dont understand why it dont work. First of all I create a network using.
$ docker network create todo-app
After that, I set up a Container mysql database and connect it with the network with following code.
$ docker run -d \
--network todo-app --network-alias mysql \
-v todo-mysql-data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=secret \
-e MYSQL_DATABASE=todos \
mysql:5.7
I check for the Container id with
$ docker ps
After that I use the command to get into the mysql CLI ? (not sure on that yet)
$ docker exec -it mysql -u root -p
After getting there I use
mysql> SHOW DATABASES;
to show all DB on my PC? But there is non listed named todos and i dont know why it dont appear.
I would like to hear what you are thinking im struggeling a little there. Thanks for the replies. Sorry for my english skills.
Run container in the foreground and check the logs.
Following Part 7: Multi-container apps, I ran into this exact issue just now.
Chances are, you have run that same command at least once.
# command to run as per the docs
docker run -d \
--network todo-app --network-alias mysql \
-v todo-mysql-data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=secret \
-e MYSQL_DATABASE=todos \
mysql:5.7
And the first time you ran the command you unknowingly made a mistake. For me, I mistyped MYSQL_DATABASE FOR MYSQL_ROOT_PASSWORD. Yours might be different. In any case, it seems making small mistakes like this might have caused the mysql:5.7 image to not be set up correctly with the todos database. (Not entirely sure.)
Adding to that, the first time you run that command, Docker creates a todo-mysql-data volume, which does not get overwritten when you run that same command again.
So as a "fix", you might have to delete the todo-mysql-data volume first.
docker volume rm todo-mysql-data
And then re-create the todo-mysql-data volume implicitly by re-running the image with the above command; this time without mistakes.
Sorry for the trouble it was my fault I guess cause I used the Command I pointed out above but I definetly had to use this command :
docker run -d \
--network todo-app --network-alias mysql \
--platform "linux/amd64" \
-v todo-mysql-data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=secret \
-e MYSQL_DATABASE=todos \
mysql:5.7
Because im using Linux... Such a dumb mistake but i swear this wasnt there two months ago when I asked this Qeustion.

run a docker mysql container and open it in one command

I want to run and open a mysql Cli in docker just with one command . Something like this is not working:
docker run --rm -it -p 33060:3306 --name mydb -e MYSQL_ROOT_PASSWORD=secret mysql mysql -p
I know I can connect to mysql after running my container this way
docker -it docker exec -it mydb mysql -p
but i want to do it in one liner.
Thanks
(Updated)*****
Seems that you can do it in version 8 calling MySQLsh at the end of the command. But unable to do it for previous versions
docker run --name=mk-mysql -p3306:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -it mysql/mysql-server:8.0.20 mysqlsh
The database server and client are two separate programs. A container only runs one program, so you can't run both the server and the client in the same container, both as the main process. You could write a script that starts the container and then runs mysql to connect to it, but that's about the best you can do.
#!/bin/sh
docker run -d -p 33060:3306 --name mydb -e MYSQL_ROOT_PASSWORD=secret mysql
exec mysql --host=127.0.0.1 --port=33060 --connect-timeout=60 --wait --password
If you're trying to do this to create a database or do other first-time initialization, you can bind-mount an initialization script into /docker-entrypoint-initdb.d and it will run as part of the database setup (only the very first time the database is started).
# Create the storage for the database
# (delete and recreate to rerun the init script)
docker volume create mysql-data
docker run \
-v mysql-data:/var/lib/mysql \
-v $PWD/init.sql:/docker-entrypoint-initdb.d/init.sql \
... \
mysql
If you're just trying to experiment with SQL commands, a serverless database like SQLite might fit your needs better.
the -p parameter is for the ports to be published and should not be part of the -it interactive, that should be your error,
Have a read of the docker run command, in the docker documentation,
https://docs.docker.com/engine/reference/run/

Docker create volume for MySQL

I'm starting to use docker implement mysql in our environment. But I have a little bit confuse about it.
1. I have tried to use command, it's working
sudo docker run --name mysql5.7 --restart always --privileged=true -p 4306:3006 -v /Users/user/mysql/config/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf -v /Users/user/mysql/data:/var/lib/mysql -e MYSQL_USER=“usr” -e MYSQL_PASSWORD=“1234” -e MYSQL_ROOT_PASSWORD=“1234” -d mysql:5.7
But follow docker document, they suggest use volume to persist data. So I tried crate a volume first docker volume -d create local mysql_v
try to link mysql to volume mysql_v, but I don't know how to do it and what is different with step 1.
anyone can suggest it ~?
Like
docker run --name mysql5.7 --restart always -p 4306:3006 \
-v /Users/user/mysql/config/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf \
-v mysql_v:/var/lib/mysql \
-e MYSQL_USER=“usr” -e MYSQL_PASSWORD=“1234” \
-e MYSQL_ROOT_PASSWORD=“1234” -d mysql:5.7
Note, privileged removed, that's just asking for trouble
Ref: official documents

"docker container run" requires at least 1 argument

I'm trying to create a container using a volume that I have already created, but my console shows the error
docker container run" requires at least 1 argument
This is the command I'm trying to run:
docker container run --name db -v volume-dados-do-banco:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Mypass
I have also tried this one, wih more arguments, but the same error persists:
docker container run -d --name db -p 3306:3306 -e 'ACCEPT_EULA=Y' -e MYSQL_ROOT_PASSWORD=Mypass -v volume-dados-do-banco:/var/lib/mysql
Any thoughts on the reason why this is happening?
Problem is not with docker, you just didn't specify which image to run. Your command should include Docker image as per documentation.
docker run [OPTIONS] IMAGE[:TAG|#DIGEST] [COMMAND] [ARG...]
Example would be:
docker run -d --name db -v volume-dados-do-banco:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Mypass mysql:latest
i just had the same problem with psql my password simply contained & and i needed to escape it with / before &
try the below command.. it seems a syntax error on your command..
docker container run -d --name db -v volume-dados-do-banco:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Mypass
i have the same problem when i use this:
docker run -d -p 3306:3306 -v /Volumes/wd4black/mysql -e MYSQL_ROOT_PASSWORD=root mysql
but when i try below, the problem is disappear:
docker run --name my-s -d -p 3306:3306 -v /Volumes/wd4black/mysql -e MYSQL_ROOT_PASSWORD=root mysql
so i think the --name is key, but the doc didn/t write it.
I just restarted docker and ran:
docker run --name torgmysqldb --volumes-from volume-dados-banco-mysql -e MYSQL_ROOT_PASSWORD=Mypass -p 3307:3306 mysql
I found out a known issue about this:
https://github.com/docker/for-win/issues/2722
After you have extracted the image from the Docker repository, you can move on to deploying the new Container with the following code snippet:
sudo docker run --name=[container_name] -d [image_tag_name]

Several flume sinks in the same agent.conf file

Is it possible to have several flume's agents (sinks) under the same configuration file (agent.conf)?
I think so. It is a matter of include all the per-sinks configuration in the same agent.conf file. There is an example here.
The preferred way for FIWARE is using Dockers. So, let's imagine we need a Cygnus and we want the data to be "sinked" to MongoDB and MySQL.
A good practice would consist of making a Docker-compose file in order to build the application, but in this case, I'll show how to deploy all dockers needed separately.
We want to deploy a MySQL so Cygnus can store data in it. We can do it this way:
sudo docker run --name mysql_showcases \
-e MYSQL_ROOT_PASSWORD=root \
-e MYSQL_DATABASE=dbcygnus \
-e MYSQL_USER=cygnus \
-e MYSQL_PASSWORD=cygnus \
-e MYSQL_ROOT_HOST='%' \
-p 3306:3306 -it -v /data/mysql:/var/lib/mysql -d -h mysql mysql/mysql-server:5.5
We want to deploy a MongoDB so Cygnus can also store data in it. We can do it this way:
sudo docker run --name mongo_showcases -v /data/mongodb:/data/db -d \
-h mongo mongo:3.6
Finally, we can deploy Cygnus using a Docker linked with both previous dockers:
docker run -d --name cygnus_showcases --link mysql_showcases --link mongo_showcases \
-p 8081:8081 -p 5050:5050 \
-e CYGNUS_MYSQL_HOST=mysql_showcases -e CYGNUS_MYSQL_PORT=3306 \
-e CYGNUS_MYSQL_USER=root -e CYGNUS_MYSQL_PASS=root \
-e CYGNUS_MONGO_HOSTS=mongo_showcases:27017 \
fiware/cygnus-ngsi
So, we've deployed a Docker, using Cygnus which will store data in a MongoDB and a MySQL database. We can also provide more "variables" to configure other sinks to where to store data in.