Docker - mysql configured with empty password for the root user - spring-boot

I am new to docker and try to run a mysql image using below command on a windows server.
docker run -e MYSQL_ROOT_PASSWORD=sEe#21 -e MYSQL_DATABASE=emp_db -p 3306:3306 --name mysql_emp mysql
It successfully downloaded and configured. I am getting a log in the CMD which says
root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
I have already given the root password which I set to use by the application and hence I get an error saying that cannot connect to DB from the spring boot service. MySQL full log is as follows
2021-02-10 14:25:43+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-02-10 14:25:43+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-02-10 14:25:43+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-02-10 14:25:43+00:00 [Note] [Entrypoint]: Initializing database files
2021-02-10T14:25:43.801929Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.23) initializing of server in progress as process 43
2021-02-10T14:25:43.808218Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-02-10T14:25:44.547274Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-02-10T14:25:46.632843Z 6 [Warning] [MY-010453] [Server] root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2021-02-10 14:25:51+00:00 [Note] [Entrypoint]: Database files initialized
2021-02-10 14:25:51+00:00 [Note] [Entrypoint]: Starting temporary server
2021-02-10T14:25:51.770335Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.23) starting as process 88
2021-02-10T14:25:51.804446Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-02-10T14:25:52.039318Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-02-10T14:25:52.169969Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
2021-02-10T14:25:52.299951Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-02-10T14:25:52.300259Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-02-10T14:25:52.304466Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2021-02-10T14:25:52.327240Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.23' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server - GPL.
2021-02-10 14:25:52+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2021-02-10 14:25:58+00:00 [Note] [Entrypoint]: Creating database emp_db
2021-02-10 14:25:58+00:00 [Note] [Entrypoint]: Stopping temporary server
2021-02-10T14:25:58.448858Z 11 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.23).
2021-02-10T14:26:00.212816Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.23) MySQL Community Server - GPL.
2021-02-10 14:26:00+00:00 [Note] [Entrypoint]: Temporary server stopped
2021-02-10 14:26:00+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
2021-02-10T14:26:00.738118Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.23) starting as process 1
2021-02-10T14:26:00.763121Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-02-10T14:26:00.999006Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-02-10T14:26:01.135971Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2021-02-10T14:26:01.269210Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-02-10T14:26:01.269444Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-02-10T14:26:01.275037Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2021-02-10T14:26:01.297388Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.23' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
Would like to understand what is wrong I am doing ? any parameter is missing in the docker run command ?

It is just an example of misleading printing:
That is just a warning printed by during database file initialization (mysqld --initialize-insecure). The root user with password is created later while the database is listening only on the unix socket.
From https://github.com/docker-library/mysql/issues/307#issuecomment-313784886

What happens if you structure your run command as it is on the MySQL Docker hub page:
docker run --name mysql_emp -e MYSQL_ROOT_PASSWORD=sEe#21 -e MYSQL_DATABASE=emp_db -p 3306:3306 -d mysql:latest
If that doesn't work you could try running from a dockerfile, similar to this question: MYSQL docker file

Related

Postgres 13 service will not start after installing Postgres 14

I have been using Postgresql 13 on a local server on my Windows 10 computer for over a year successfully now. I decided to upgrade to 14 yesterday.
I installed 14 on a different port. I went to go and upgrade as per this command: pg_upgrade -d "c:\Program Files\PostgreSQL\13\data" -D "c:\Program Files\PostgreSQL\14\data" -b "c:\Program Files\PostgreSQL\13\bin" -B "c:\Program Files\PostgreSQL\14\bin" -U Postgres, but it said it cannot connect to the 13 server. I restarted the computer, and still the 13's Service will not start.
When I type pg_ctl -D "C:\Program Files\PostgreSQL\13\data" start at the cmd line, the below is what shows in my log:
2022-02-15 08:53:45.908 +04 [92100] LOG: starting PostgreSQL 13.3, compiled by Visual C++ build 1914, 64-bit
2022-02-15 08:53:45.909 +04 [92100] LOG: listening on IPv6 address "::", port 5432
2022-02-15 08:53:45.910 +04 [92100] LOG: listening on IPv4 address "0.0.0.0", port 5432
2022-02-15 08:53:45.954 +04 [92672] LOG: database system was shut down at 2022-02-14 14:08:25 +04
2022-02-15 08:53:45.955 +04 [92672] LOG: invalid record length at 24/80B400C8: wanted 24, got 0
2022-02-15 08:53:45.955 +04 [92672] LOG: invalid primary checkpoint record
2022-02-15 08:53:45.955 +04 [92672] PANIC: could not locate a valid checkpoint record
2022-02-15 08:53:46.057 +04 [92100] LOG: startup process (PID 92672) was terminated by exception 0xC0000409
2022-02-15 08:53:46.057 +04 [92100] HINT: See C include file "ntstatus.h" for a description of the hexadecimal value.
2022-02-15 08:53:46.057 +04 [92100] LOG: aborting startup due to startup process failure
2022-02-15 08:53:46.059 +04 [92100] LOG: database system is shut down
What should I do to fix this?
What I have already done is:
PostgreSQL.conf - made sure listen_addresses = '*' was uncommented
made sure Modify was valid for all users of the computer on the Postgres Programs folder
I checked that the Postgres user had full rights to the folder, but there was no user found in my windows.
I added to the pg_hba file: #host all all 0.0.0.0/0 scram-sha-256
oh, and in case it's not apparent, I don't know much about Postgres. I can use it for what I need and that's about it.
As JJanes suggested. I did a backup and then restored in the new server of Postgres 14. It solved the problem. Thank you, JJanes.

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) on Mac Big Sur

I just upgraded to MacOS Big Sur, and I found out I can't login to mysql console with mysql -u root (without password).
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I installed MariaDB with brew (brew install mariadb)
I checked the mysql daemon, and found following error
Xuans-MacBook-Pro:~ xuan$ mysqld
2020-12-21 15:46:27 0 [Note] mysqld (mysqld 10.5.8-MariaDB) starting as process 2091 ...
2020-12-21 15:46:27 0 [Warning] Can't create test file /usr/local/var/mysql/Xuans-MacBook-Pro-2.lower-test
2020-12-21 15:46:27 0 [ERROR] mysqld: File '/usr/local/var/mysql/aria_log_control' not found (Errcode: 13 "Permission denied")
2020-12-21 15:46:27 0 [ERROR] mysqld: Got error 'Can't open file' when trying to use aria control file '/usr/local/var/mysql/aria_log_control'
2020-12-21 15:46:27 0 [ERROR] Plugin 'Aria' init function returned error.
2020-12-21 15:46:27 0 [ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed.
2020-12-21 15:46:27 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2020-12-21 15:46:27 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2020-12-21 15:46:27 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-12-21 15:46:27 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-12-21 15:46:27 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-12-21 15:46:27 0 [ERROR] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some plugins may be not loaded
2020-12-21 15:46:27 0 [ERROR] Failed to initialize plugins.
2020-12-21 15:46:27 0 [ERROR] Aborting
Here is the permission of /usr/local/var/mysql/
drwxr-xr-x 68 xuan admin 2176 21 Dec 15:48 mysql
socket file location
Xuans-MacBook-Pro:xuan$ mysqld --help --verbose | grep sock
socket /tmp/mysql.sock
unix-socket ON
Any suggestions?
I had this same issue on a 2018 macbook pro with an i9 running big sur 11.1
I could link to a mysql database with mysql workbench and datagrip no problem but when I tried to access mysql from the terminal i got "can't connect to local MYSQL server through socket."
I dropped back to the /usr/local/mysql/bin and ran ./mysql -u root -p and it connects.
Is this a big sur security issue? MAMP is running. The MYSQL editors act normal. It seems big sur will not allow the socket connect through MAMP.
Login as user root via socket requires that the owner of the socket is root, not any other user, since authentication will performed via unix socket authentication.
so a simple sudo mysql -uroot should work.

Cannot connect to mySQL after recovering InnoDB tables without Ibdata1 file [xampp and localhost]

First of all, you should know that I have few knowledge of mySQL, databases, xampp and so on. I will try to explain my problem the best I can.
Secondly, notice that I have already searched for solutions in this site and others, but I do not find anyone that applies to my specific situation.
I was developing my first wordpress website using bitnami_wordpress and xampp. A few days ago I had a problem connecting to a mySQL local server. Due to my ignorance, when I was trying to solve my problem, I ended up overwriting the ibdata1 file from my xampp/mysql/data folder with the one stored in xampp\mysql\backup. Big mistake! The backup may be too old and now my database was "corrupted". When I tried to access the tables in the phpmyadmin panel there was a message saying "table doesn't exist in engine".
I looked for solutions in the net and I finally decided to follow these steps to restore my data: https://zadpen.com/20-restore-lost-data-in-mysql-using-innodb-engine-without-file-ibdata1.html
These are the main steps:
Add innodb_file_per_table=1 in xampp\mysql\bin\my.ini
Create a new database for the website (I used same name as the original one while I changed the name of the old one)
Recovering the tables structure of the old database. For example: mysqlfrm --server=root:#localhost:3306 wp_cn_social_icon.frm --port 3333 > wp_cn_social_icon.sql
Creating the table using the SQL statements of the previous step.
Discard the .ibd files of the new database ALTER TABLE wp_cn_social_icon DISCARD TABLESPACE;
Copying the original .ibd file from the old database to the new one.
"linking" the .ibd to the .frm file of the new database: ALTER TABLE wp_cn_social_icon IMPORT TABLESPACE;
I repeated these steps for all the tables.
It worked. I was able to see again all the data in the tables in the phpmyadmin control panel! I was so happy! HOWEVER, happiness lasted a few minutes. As soon as I stopped Xampp and restarted it again, I found up that I was able to access other databases in the phpMyAdmin panel, but not the website database I was interested in. This was the error:
I think nothing is wrong in the configInc.php file...is it?
/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Lang'] = '';
/* Bind to the localhost ipv4 address and tcp */
$cfg['Servers'][$i]['host'] = '127.0.0.1:3306';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
I then tried to connect to the server through the Windows CMD (I didnt' know what to do... I was just desperate) I used the command: mysql -u root -p. And then I write down: mysql use website_database. After doing this, the connection was interrupted and I have not been able to start again the mysql server.
Now Xampp shows this error everytime I attempt to start MySQL.
16:45:33 [mysql] Attempting to start MySQL app...
16:45:33 [mysql] Status change detected: running
16:45:36 [mysql] Status change detected: stopped
16:45:36 [mysql] Error: MySQL shutdown unexpectedly.
16:45:36 [mysql] This may be due to a blocked port, missing dependencies,
16:45:36 [mysql] improper privileges, a crash, or a shutdown by another method.
16:45:36 [mysql] Press the Logs button to view error logs and check
16:45:36 [mysql] the Windows Event Viewer for more clues
16:45:36 [mysql] If you need more help, copy and post this
16:45:36 [mysql] entire log window on the forums
The mysql_error.log file shows this:
2020-06-06 16:45:34 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2020-06-06 16:45:34 0 [Note] InnoDB: Uses event mutexes
2020-06-06 16:45:34 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-06-06 16:45:34 0 [Note] InnoDB: Number of pools: 1
2020-06-06 16:45:34 0 [Note] InnoDB: Using SSE2 crc32 instructions
2020-06-06 16:45:34 0 [Note] InnoDB: Initializing buffer pool, total size = 16M, instances = 1, chunk size = 16M
2020-06-06 16:45:34 0 [Note] InnoDB: Completed initialization of buffer pool
2020-06-06 16:45:34 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2020-06-06 16:45:34 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-06-06 16:45:34 0 [Note] InnoDB: Setting file 'C:\Program Files\xampp\mysql\data\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-06-06 16:45:34 0 [Note] InnoDB: File 'C:\Program Files\xampp\mysql\data\ibtmp1' size is now 12 MB.
2020-06-06 16:45:34 0 [Note] InnoDB: Waiting for purge to start
2020-06-06 16:45:34 0 [Note] InnoDB: 10.4.11 started; log sequence number 896271; transaction id 990
2020-06-06 16:45:34 0 [Note] InnoDB: Loading buffer pool(s) from C:\Program Files\xampp\mysql\data\ib_buffer_pool
2020-06-06 16:45:34 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-06-06 16:45:34 0 [Note] Server socket created on IP: '::'.
I did not change any connection settings... I Just followed the steps of that website to recover the data. What may be wrong? I must be doing something wrong or missing something related with the connecting settings.
PS: Just in case, I found strange that Ibdata1 file weighs now almost 70Mb...

Docker Percona exits with error 3 in macOS

Using Docker Toolbox in macOS 10.11. Trying to start Percona 5.7 container via docker-compose:
percona:
image: percona:5.7
user: "1000:50"
restart: "no"
volumes:
- ./db:/var/lib/mysql:rw
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: qwerty
But when run:
docker-compose up
it shows me this log:
percona_1 | Initializing database
percona_1 | 2018-02-27T18:21:40.471171Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
percona_1 | 2018-02-27T18:21:40.471336Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
percona_1 | 2018-02-27T18:21:40.509126Z 0 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
percona_1 | 2018-02-27T18:21:40.511757Z 0 [Warning] One can only use the --user switch if running as root
percona_1 |
percona_1 | 2018-02-27T18:21:42.900823Z 0 [ERROR] InnoDB: Operating system error number 22 in a file operation.
percona_1 | 2018-02-27T18:21:42.901071Z 0 [ERROR] InnoDB: Error number 22 means 'Invalid argument'
percona_1 | 2018-02-27T18:21:42.901164Z 0 [ERROR] InnoDB: File ./ib_logfile101: 'aio write' returned OS error 122. Cannot continue operation
percona_1 | 2018-02-27T18:21:42.901187Z 0 [ERROR] InnoDB: Cannot continue operation.
docker_percona_1 exited with code 3
Can you help me understand the problem?
It means the filesystem your using doesn't support aio. You can tell this to innodb by adding the following line to my.cnf:
innodb_use_native_aio=0
also remove innodb_flush_method = O_DIRECT if enabled in my.cnf

Error "mysqld dead but pid file exists"

I get the error "mysqld dead but pid file exists"
I have a acache webclient running on EC2. With WordPress. I started seeing "error in Databse Connection"
When i do a sudo service mysqld status i See the error "mysqld dead but pid file exists"
Looks like I have enough space
[root#ip-10-0-0-149 log]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.8G 1.5G 6.3G 19% /
devtmpfs 486M 56K 486M 1% /dev
tmpfs 499M 0 499M 0% /dev/shm
Also when i do a tail I get
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
140717 21:04:58 InnoDB: Waiting for the background threads to start
140717 21:04:59 InnoDB: 5.5.38 started; log sequence number 6150055
140717 21:04:59 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
140717 21:04:59 [Note] - '0.0.0.0' resolves to '0.0.0.0';
140717 21:04:59 [Note] Server socket created on IP: '0.0.0.0'.
140717 21:04:59 [Note] Event Scheduler: Loaded 0 events
140717 21:04:59 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.38' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL)
Please Help !
in my case I did this and my problem solved.
cd /var/run/mysqld
rm -f mysqld.pid

Resources