Running 2 installations of Wordpress in Docker - mysql
I'm trying to run 2 separate installations of Wordpress in Docker, but I'm having conflicts with the databases.
Here's what I've tried so far:
I runned the below code and got the logs also below.
Open putty > nano docker-compose.yml > pasted the below code > docker-compose up -d
version: '3.1'
services:
wordpress_multi_1:
image: wordpress
restart: always
ports:
- 11:80 ##change_this
environment:
WORDPRESS_DB_HOST: db_multi_1
WORDPRESS_DB_USER: exampleuser_multi_1
WORDPRESS_DB_PASSWORD: examplepass_multi_1
WORDPRESS_DB_NAME: exampledb_multi_1
volumes:
- /srv/dev-disk-by-label-1TB/Config/wordpress_multi_1:/var/www/html ##change_this
db_multi_1:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb_multi_1
MYSQL_USER: exampleuser_multi_1
MYSQL_PASSWORD: examplepass_multi_1
MYSQL_RANDOM_ROOT_PASSWORD: '1' #I didn´t changed this
volumes:
- /srv/dev-disk-by-label-1TB/Config/wordpress_multi_3/db1:/var/lib/mysql
# Other Instalation
wordpress_multi_2: #2nd_instance
image: wordpress
restart: always
ports:
- 12:80 ##change_this
environment:
WORDPRESS_DB_HOST: db_multi_2 #point to 2nd db instance
WORDPRESS_DB_USER: exampleuser_multi_2
WORDPRESS_DB_PASSWORD: examplepass_multi_2
WORDPRESS_DB_NAME: exampledb_multi_2
volumes:
- /srv/dev-disk-by-label-1TB/Config/wordpress_multi_2:/var/www/html ##change_this
db_multi_2: #2nd_instance
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb_multi_2
MYSQL_USER: exampleuser_multi_2
MYSQL_PASSWORD: examplepass_multi_2
MYSQL_RANDOM_ROOT_PASSWORD: '1' #I didn´t changed this
volumes:
- /srv/dev-disk-by-label-1TB/Config/wordpress_multi_2/db2:/var/lib/mysql
volumes: ##remove these line if you bind the volume to host machine
wordpress_multi_1:
db_multi_1:
wordpress_multi_2:
db_multi_2:
I can´t access the first container in MY-IP:11 ,
when I access 2nd container MY-IP:12 I get this error message Error establishing a database connection
I have this in the container logs:
In the Logs of root wordpress multi _1_1 I have this
[25-Jul-2020 15:53:03 UTC] PHP Warning: mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22
MySQL Connection Error: (2002) Connection refused
MySQL Connection Error: (2002) Connection refused
MySQL Connection Error: (2002) Connection refused
MySQL Connection Error: (2002) Connection refused
MySQL Connection Error: (2002) Connection refused
MySQL Connection Error: (2002) Connection refused
MySQL Connection Error: (2002) Connection refused
MySQL Connection Error: (2002) Connection refused
MySQL Connection Error: (2002) Connection refused
MySQL Connection Error: (2002) Connection refused
WARNING: unable to establish a database connection to 'db_multi_1'
continuing anyways (which might have unexpected results)
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.27.0.3. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.27.0.3. Set the 'ServerName' directive globally to suppress this message
[Sat Jul 25 15:53:30.918212 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.4.8 configured -- resuming normal operations
[Sat Jul 25 15:53:30.918429 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
In the Logs of root_db_multi_1_1 I have this
2020-07-25 15:53:59+00:00 [Note] [Entrypoint]: Creating user exampleuser,
2020-07-25 15:53:59+00:00 [Note] [Entrypoint]: Giving user exampleuser access to schema exampledb,
,
2020-07-25 15:53:59+00:00 [Note] [Entrypoint]: Stopping temporary server,
2020-07-25T15:53:59.954860Z 0 [Note] Giving 0 client threads a chance to die gracefully,
2020-07-25T15:53:59.954994Z 0 [Note] Shutting down slave threads,
2020-07-25T15:53:59.955028Z 0 [Note] Forcefully disconnecting 0 remaining clients,
2020-07-25T15:53:59.955057Z 0 [Note] Event Scheduler: Purging the queue. 0 events,
2020-07-25T15:53:59.955668Z 0 [Note] Binlog end,
2020-07-25T15:53:59.957922Z 0 [Note] Shutting down plugin 'ngram',
2020-07-25T15:53:59.957982Z 0 [Note] Shutting down plugin 'partition',
2020-07-25T15:53:59.958006Z 0 [Note] Shutting down plugin 'BLACKHOLE',
2020-07-25T15:53:59.958027Z 0 [Note] Shutting down plugin 'ARCHIVE',
2020-07-25T15:53:59.958045Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA',
2020-07-25T15:53:59.958138Z 0 [Note] Shutting down plugin 'MRG_MYISAM',
2020-07-25T15:53:59.958162Z 0 [Note] Shutting down plugin 'MyISAM',
2020-07-25T15:53:59.958196Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL',
2020-07-25T15:53:59.958218Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES',
2020-07-25T15:53:59.958240Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES',
2020-07-25T15:53:59.958257Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS',
2020-07-25T15:53:59.958274Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN',
2020-07-25T15:53:59.958291Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS',
2020-07-25T15:53:59.958308Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS',
2020-07-25T15:53:59.958325Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES',
2020-07-25T15:53:59.958378Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS',
2020-07-25T15:53:59.958400Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES',
2020-07-25T15:53:59.958421Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE',
2020-07-25T15:53:59.958439Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE',
2020-07-25T15:53:59.958458Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG',
2020-07-25T15:53:59.958477Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED',
2020-07-25T15:53:59.958496Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED',
2020-07-25T15:53:59.958515Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD',
2020-07-25T15:53:59.958535Z 0 [Note] Shutting down plugin 'INNODB_METRICS',
2020-07-25T15:53:59.958555Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO',
2020-07-25T15:53:59.958575Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS',
2020-07-25T15:53:59.958595Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU',
2020-07-25T15:53:59.958614Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE',
2020-07-25T15:53:59.958633Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET',
2020-07-25T15:53:59.958652Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX',
2020-07-25T15:53:59.958672Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET',
2020-07-25T15:53:59.958696Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM',
2020-07-25T15:53:59.958715Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET',
2020-07-25T15:53:59.958732Z 0 [Note] Shutting down plugin 'INNODB_CMP',
2020-07-25T15:53:59.958755Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS',
2020-07-25T15:53:59.958773Z 0 [Note] Shutting down plugin 'INNODB_LOCKS',
2020-07-25T15:53:59.958792Z 0 [Note] Shutting down plugin 'INNODB_TRX',
2020-07-25T15:53:59.958813Z 0 [Note] Shutting down plugin 'InnoDB',
2020-07-25T15:53:59.959041Z 0 [Note] InnoDB: FTS optimize thread exiting.,
2020-07-25T15:53:59.959779Z 0 [Note] InnoDB: Starting shutdown...,
2020-07-25T15:54:00.060456Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool,
2020-07-25T15:54:00.062402Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 200725 15:54:00,
2020-07-25T15:54:02.601970Z 0 [Note] InnoDB: Shutdown completed; log sequence number 12578970,
2020-07-25T15:54:02.606084Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1",
2020-07-25T15:54:02.606173Z 0 [Note] Shutting down plugin 'MEMORY',
2020-07-25T15:54:02.606192Z 0 [Note] Shutting down plugin 'CSV',
2020-07-25T15:54:02.606207Z 0 [Note] Shutting down plugin 'sha256_password',
2020-07-25T15:54:02.606218Z 0 [Note] Shutting down plugin 'mysql_native_password',
2020-07-25T15:54:02.606496Z 0 [Note] Shutting down plugin 'binlog',
2020-07-25T15:54:02.610743Z 0 [Note] mysqld: Shutdown complete,
,
2020-07-25 15:54:02+00:00 [Note] [Entrypoint]: Temporary server stopped,
,
2020-07-25 15:54:02+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.,
,
2020-07-25T15:54:03.386358Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).,
2020-07-25T15:54:03.392303Z 0 [Note] mysqld (mysqld 5.7.31) starting as process 1 ...,
2020-07-25T15:54:03.404842Z 0 [Note] InnoDB: PUNCH HOLE support available,
2020-07-25T15:54:03.404912Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins,
2020-07-25T15:54:03.404931Z 0 [Note] InnoDB: Uses event mutexes,
2020-07-25T15:54:03.404949Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier,
2020-07-25T15:54:03.404967Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11,
2020-07-25T15:54:03.404984Z 0 [Note] InnoDB: Using Linux native AIO,
2020-07-25T15:54:03.405903Z 0 [Note] InnoDB: Number of pools: 1,
2020-07-25T15:54:03.406261Z 0 [Note] InnoDB: Using CPU crc32 instructions,
2020-07-25T15:54:03.412184Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M,
2020-07-25T15:54:03.450230Z 0 [Note] InnoDB: Completed initialization of buffer pool,
2020-07-25T15:54:03.458769Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().,
2020-07-25T15:54:03.477366Z 0 [Note] InnoDB: Highest supported file format is Barracuda.,
2020-07-25T15:54:03.572954Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables,
2020-07-25T15:54:03.573169Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...,
2020-07-25T15:54:04.136273Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.,
2020-07-25T15:54:04.140875Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.,
2020-07-25T15:54:04.140953Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.,
2020-07-25T15:54:04.142674Z 0 [Note] InnoDB: Waiting for purge to start,
2020-07-25T15:54:04.194101Z 0 [Note] InnoDB: 5.7.31 started; log sequence number 12578970,
2020-07-25T15:54:04.196142Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool,
2020-07-25T15:54:04.198000Z 0 [Note] Plugin 'FEDERATED' is disabled.,
2020-07-25T15:54:04.214845Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200725 15:54:04,
2020-07-25T15:54:04.223928Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.,
2020-07-25T15:54:04.223996Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.,
2020-07-25T15:54:04.225843Z 0 [Warning] CA certificate ca.pem is self signed.,
2020-07-25T15:54:04.225943Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.,
2020-07-25T15:54:04.227467Z 0 [Note] Server hostname (bind-address): '*'; port: 3306,
2020-07-25T15:54:04.227657Z 0 [Note] IPv6 is available.,
2020-07-25T15:54:04.227691Z 0 [Note] - '::' resolves to '::';,
2020-07-25T15:54:04.227764Z 0 [Note] Server socket created on IP: '::'.,
2020-07-25T15:54:04.259808Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.,
2020-07-25T15:54:04.296032Z 0 [Note] Event Scheduler: Loaded 0 events,
2020-07-25T15:54:04.298053Z 0 [Note] mysqld: ready for connections.,
Version: '5.7.31' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL),
In the Logs of root wordpress multi_2_1 I have this:
[25-Jul-2020 15:53:03 UTC] PHP Warning: mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22,
,
MySQL Connection Error: (2002) Connection refused,
[25-Jul-2020 15:53:06 UTC] PHP Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES) in Standard input code on line 22,
,
MySQL Connection Error: (1045) Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
,
MySQL Connection Error: (1045) Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
,
MySQL Connection Error: (1045) Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
,
MySQL Connection Error: (1045) Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
,
MySQL Connection Error: (1045) Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
,
MySQL Connection Error: (1045) Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
,
MySQL Connection Error: (1045) Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
,
MySQL Connection Error: (1045) Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
,
MySQL Connection Error: (1045) Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
,
WARNING: unable to establish a database connection to 'db_multi_2',
continuing anyways (which might have unexpected results),
,
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.27.0.5. Set the 'ServerName' directive globally to suppress this message,
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.27.0.5. Set the 'ServerName' directive globally to suppress this message,
[Sat Jul 25 15:53:30.922486 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.4.8 configured -- resuming normal operations,
[Sat Jul 25 15:53:30.922705 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND',
192.168.1.21 - - [25/Jul/2020:15:53:48 +0000] "GET / HTTP/1.1" 500 2952 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36",
192.168.1.21 - - [25/Jul/2020:15:53:49 +0000] "GET /favicon.ico HTTP/1.1" 500 2952 "http://192.168.1.198:12/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36",
192.168.1.21 - - [25/Jul/2020:16:01:07 +0000] "GET / HTTP/1.1" 500 2952 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36",
192.168.1.21 - - [25/Jul/2020:16:01:08 +0000] "GET /favicon.ico HTTP/1.1" 500 2952 "http://192.168.1.198:12/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36",
In the Logs of root_db_multi_2_1 I have this
2020-07-25 15:53:02+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started.,
2020-07-25 15:53:02+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql',
2020-07-25 15:53:02+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started.,
2020-07-25T15:53:03.349210Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).,
2020-07-25T15:53:03.355966Z 0 [Note] mysqld (mysqld 5.7.31) starting as process 1 ...,
2020-07-25T15:53:03.369477Z 0 [Note] InnoDB: PUNCH HOLE support available,
2020-07-25T15:53:03.369554Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins,
2020-07-25T15:53:03.369574Z 0 [Note] InnoDB: Uses event mutexes,
2020-07-25T15:53:03.369600Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier,
2020-07-25T15:53:03.369618Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11,
2020-07-25T15:53:03.369636Z 0 [Note] InnoDB: Using Linux native AIO,
2020-07-25T15:53:03.370895Z 0 [Note] InnoDB: Number of pools: 1,
2020-07-25T15:53:03.371337Z 0 [Note] InnoDB: Using CPU crc32 instructions,
2020-07-25T15:53:03.379153Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M,
2020-07-25T15:53:03.423703Z 0 [Note] InnoDB: Completed initialization of buffer pool,
2020-07-25T15:53:03.432259Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().,
2020-07-25T15:53:03.449044Z 0 [Note] InnoDB: Highest supported file format is Barracuda.,
2020-07-25T15:53:03.749813Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 12578846,
2020-07-25T15:53:03.750534Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 12578855,
2020-07-25T15:53:03.750614Z 0 [Note] InnoDB: Database was not shutdown normally!,
2020-07-25T15:53:03.750659Z 0 [Note] InnoDB: Starting crash recovery.,
2020-07-25T15:53:03.952127Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1",
2020-07-25T15:53:03.952210Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables,
2020-07-25T15:53:03.952808Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...,
2020-07-25T15:53:05.161161Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.,
2020-07-25T15:53:05.168757Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.,
2020-07-25T15:53:05.168874Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.,
2020-07-25T15:53:05.172052Z 0 [Note] InnoDB: 5.7.31 started; log sequence number 12578855,
2020-07-25T15:53:05.173264Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool,
2020-07-25T15:53:05.174026Z 0 [Note] Plugin 'FEDERATED' is disabled.,
2020-07-25T15:53:05.187982Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200725 15:53:05,
2020-07-25T15:53:05.195363Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.,
2020-07-25T15:53:05.195433Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.,
2020-07-25T15:53:05.197818Z 0 [Warning] CA certificate ca.pem is self signed.,
2020-07-25T15:53:05.197923Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.,
2020-07-25T15:53:05.199723Z 0 [Note] Server hostname (bind-address): '*'; port: 3306,
2020-07-25T15:53:05.199889Z 0 [Note] IPv6 is available.,
2020-07-25T15:53:05.199923Z 0 [Note] - '::' resolves to '::';,
2020-07-25T15:53:05.199996Z 0 [Note] Server socket created on IP: '::'.,
2020-07-25T15:53:05.232986Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.,
2020-07-25T15:53:05.269606Z 0 [Note] Event Scheduler: Loaded 0 events,
2020-07-25T15:53:05.271134Z 0 [Note] mysqld: ready for connections.,
Version: '5.7.31' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL),
2020-07-25T15:53:06.493594Z 2 [Note] Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
2020-07-25T15:53:09.499889Z 3 [Note] Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
2020-07-25T15:53:12.505293Z 4 [Note] Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
2020-07-25T15:53:15.510159Z 5 [Note] Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
2020-07-25T15:53:18.515748Z 6 [Note] Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
2020-07-25T15:53:21.522246Z 7 [Note] Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
2020-07-25T15:53:24.528657Z 8 [Note] Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
2020-07-25T15:53:27.534936Z 9 [Note] Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
2020-07-25T15:53:30.538996Z 10 [Note] Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
2020-07-25T15:53:49.230001Z 11 [Note] Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
2020-07-25T15:53:49.697588Z 12 [Note] Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
2020-07-25T16:01:07.993591Z 13 [Note] Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
2020-07-25T16:01:08.232897Z 14 [Note] Access denied for user 'exampleuser'#'172.27.0.5' (using password: YES),
Can someone tell me what I am doing wrong? Or fix the code/stack I tried to run? I'm not an experienced user.
I had other installations of Wordpress in the past that I deleted and I am thinking that may be causing the conflicts... I don't know... I tried some diferences in the stack files that I searched the internet, renamed the containers, but I keep getting the same errors, and I am out of ideas.
Any solution will be appreciated. Thanks.
I'm running Open Media Vault > Docker > Portainer.
You are binding multiple volumes under same root of wordpress_multi_2.This is not a good way to mount volumes. Split them to separate folders (example for /wp and /db). And do not bind ports under 1024, as they are reserved, common convention for plaintext HTTP ports is like 8080 on development machines.
wordpress_multi_1:
...
ports:
- 8080:80
...
volumes:
- /srv/dev-disk-by-label-1TB/Config/wordpress_multi_1/wp:/var/www/html
db_multi_1:
...
volumes:
- /srv/dev-disk-by-label-1TB/Config/wordpress_multi_1/db:/var/lib/mysql
wordpress_multi_2: #2nd_instance
...
ports:
- 8081:80
...
volumes:
- /srv/dev-disk-by-label-1TB/Config/wordpress_multi_2/wp:/var/www/html
db_multi_2: #2nd_instance
...
volumes:
- /srv/dev-disk-by-label-1TB/Config/wordpress_multi_2/db:/var/lib/mysql
I finally got it to work!! And i even run a second Stack with a 3 and 4 installation just to check!
Following your advice, i changed the paths and the ports, and also added some things to the code, to be honest i´m not sure on what worked, but it´s working!
i added this:
links:
- db_multi_1
depends_on:
- db_multi_1
command: --default-authentication-plugin=mysql_native_password
One thing i noticed is that mysql container takes some minutes to fully start, only after that, the wordpress / MY-IP:8001 can work correctly.
Thanks for pointing me in the wright direction.
Full Stack:
version: '2.1'
services:
wordpress_multi_1:
image: wordpress
restart: always
ports:
- 8001:80 ##change_this to above 1024
links:
- db_multi_1
depends_on:
- db_multi_1
environment:
WORDPRESS_DB_HOST: db_multi_1
WORDPRESS_DB_USER: exampleuser_multi_1
WORDPRESS_DB_PASSWORD: examplepass_multi_1
WORDPRESS_DB_NAME: exampledb_multi_1
volumes:
- /srv/dev-disk-by-label-1TB/Config/wordpress_multi_1/wp:/var/www/html ##change_this #Split them to separate folders (example for /wp and /db)
db_multi_1:
command: --default-authentication-plugin=mysql_native_password
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb_multi_1
MYSQL_USER: exampleuser_multi_1
MYSQL_PASSWORD: examplepass_multi_1
MYSQL_RANDOM_ROOT_PASSWORD: '1' #don´t change
volumes:
- /srv/dev-disk-by-label-1TB/Config/wordpress_multi_1/db:/var/lib/mysql
# networks:
# local
# Other INstalation
wordpress_multi_2: #2nd_instance
image: wordpress
restart: always
ports:
- 8002:80 ##change_this
links:
- db_multi_2
depends_on:
- db_multi_2
environment:
WORDPRESS_DB_HOST: db_multi_2 #:3306 #point to 2nd db instance
WORDPRESS_DB_USER: exampleuser_multi_2
WORDPRESS_DB_PASSWORD: examplepass_multi_2
WORDPRESS_DB_NAME: exampledb_multi_2
volumes:
- /srv/dev-disk-by-label-1TB/Config/wordpress_multi_2/wp:/var/www/html ##change_this
db_multi_2: #2nd_instance
command: --default-authentication-plugin=mysql_native_password #resulta?
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb_multi_2
MYSQL_USER: exampleuser_multi_2
MYSQL_PASSWORD: examplepass_multi_2
MYSQL_RANDOM_ROOT_PASSWORD: '1' #don´t change
volumes:
- /srv/dev-disk-by-label-1TB/Config/wordpress_multi_2/db:/var/lib/mysql
# networks:
# local
volumes: ##remove these line if you bind the volume to host machine
wordpress_multi_1:
db_multi_1:
wordpress_multi_2:
db_multi_2:
Related
Access denied for user 'root' Mysql container
I m trying to dockerize a laravel project a small problem with my MySQL Container. I cant connect to the container my DB with root or simple user. I only used docker-compose build && docker-compose up -d docker exec -it ica-backoffice_attendize_db_1 /bin/bash mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES) This is my docker log : docker logs ica-backoffice_attendize_db_1 2021-03-30 12:20:44+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.33-1debian10 started. 2021-03-30 12:20:44+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2021-03-30 12:20:44+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.33-1debian10 started. 2021-03-30T12:20:44.525563Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2021-03-30T12:20:44.527413Z 0 [Note] mysqld (mysqld 5.7.33) starting as process 1 ... 2021-03-30T12:20:44.532377Z 0 [Note] InnoDB: PUNCH HOLE support available 2021-03-30T12:20:44.532396Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2021-03-30T12:20:44.532402Z 0 [Note] InnoDB: Uses event mutexes 2021-03-30T12:20:44.532407Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2021-03-30T12:20:44.532425Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11 2021-03-30T12:20:44.532430Z 0 [Note] InnoDB: Using Linux native AIO 2021-03-30T12:20:44.532739Z 0 [Note] InnoDB: Number of pools: 1 2021-03-30T12:20:44.532879Z 0 [Note] InnoDB: Using CPU crc32 instructions 2021-03-30T12:20:44.535236Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2021-03-30T12:20:44.546880Z 0 [Note] InnoDB: Completed initialization of buffer pool 2021-03-30T12:20:44.549449Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2021-03-30T12:20:44.561014Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2021-03-30T12:20:44.562673Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 12665801 2021-03-30T12:20:44.562685Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 12665810 2021-03-30T12:20:44.562690Z 0 [Note] InnoDB: Database was not shutdown normally! 2021-03-30T12:20:44.562695Z 0 [Note] InnoDB: Starting crash recovery. 2021-03-30T12:20:44.713371Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1" 2021-03-30T12:20:44.713417Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2021-03-30T12:20:44.713562Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2021-03-30T12:20:45.454122Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2021-03-30T12:20:45.456067Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active. 2021-03-30T12:20:45.456099Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 2021-03-30T12:20:45.456761Z 0 [Note] InnoDB: Waiting for purge to start 2021-03-30T12:20:45.507075Z 0 [Note] InnoDB: 5.7.33 started; log sequence number 12665810 2021-03-30T12:20:45.507543Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool 2021-03-30T12:20:45.507941Z 0 [Note] Plugin 'FEDERATED' is disabled. 2021-03-30T12:20:45.511918Z 0 [Note] InnoDB: Buffer pool(s) load completed at 210330 12:20:45 2021-03-30T12:20:45.524384Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them. 2021-03-30T12:20:45.524418Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory. 2021-03-30T12:20:45.526363Z 0 [Warning] CA certificate ca.pem is self signed. 2021-03-30T12:20:45.526435Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory. 2021-03-30T12:20:45.527538Z 0 [Note] Server hostname (bind-address): '*'; port: 3306 2021-03-30T12:20:45.527717Z 0 [Note] IPv6 is available. 2021-03-30T12:20:45.527762Z 0 [Note] - '::' resolves to '::'; 2021-03-30T12:20:45.527810Z 0 [Note] Server socket created on IP: '::'. 2021-03-30T12:20:45.578895Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. 2021-03-30T12:20:45.602259Z 0 [Note] Event Scheduler: Loaded 0 events 2021-03-30T12:20:45.602848Z 0 [Note] mysqld: ready for connections. Version: '5.7.33' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL) 2021-03-30T12:20:56.582691Z 2 [Note] Access denied for user 'root'#'localhost' (using password: NO) 2021-03-30T12:21:22.098439Z 3 [Note] Access denied for user 'dhia'#'localhost' (using password: YES) 2021-03-30T12:21:26.702866Z 4 [Note] Access denied for user 'root'#'localhost' (using password: NO) 2021-03-30T12:21:56.174284Z 5 [Note] Access denied for user 'root'#'localhost' (using password: YES) .env file : DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=preprodica DB_USERNAME=root DB_PASSWORD=Str0ngDBP#ssw0rd Docker compose : services: attendize_app: build: context: . # The path of the Dockerfile volumes: - .:/usr/src/app depends_on: - attendize_db working_dir: /usr/src/app environment: SERVICE_NAME: attendize-app DB_CONNECTION: mysql DB_DRIVER: mysql DB_HOST: attendize_db DB_PORT: 3306 networks: - app_network attendize_nginx: build: context: ./docker-nginx/. # The path of the Dockerfile volumes: - "./public:/usr/src/app/public" environment: NGINX_FPM_HOST: attendize_app NGINX_ROOT: /usr/src/app/public ports: - "8000:80" depends_on: - attendize_app networks: - app_network attendize_db: image: mysql:5 restart: always environment: MYSQL_DATABASE: "preprodica" MYSQL_ROOT_PASSWORD: "Str0ngDBP#ssw0rd" MYSQL_USER: "dhia" MYSQL_PASSWORD: "dhia" MYSQL_ALLOW_EMPTY_PASSWORD: "yes" ports: - "3306:3306" volumes: - "./storage/db-data:/var/lib/mysql" networks: - app_network networks: app_network: driver: bridge
Docker-compose does extra work to preserve volumes between runs (thus preserving the database); you may want to try docker-compose rm -v to delete everything and try starting it up again. The command docker-compose rm -v reflects in the containers, but NOT in the volume mapped. So, the following command will remove the containers and since it doesn't delete the volumes, the command files to create a new user. $ docker-compose rm -v Going to remove backendphp_qgPhpMyAdmin_1, backendphp_qgMySQLServer_1, backendphp_qgMysqlData_1 Are you sure? [yN] y Removing backendphp_qgMysqlData_1... Removing backendphp_qgMySQLServer_1... Removing backendphp_qgPhpMyAdmin_1... At this point, the only way to make it right is to delete the directory that you mapped your mysql data. $ sudo rm -rf mysql-data Only after that, the command created a new database with the users correctly set! You can check this link too https://www.programmersought.com/article/16512825562/
I Fixed using : sudo rm -r db-data/ docker-compose up -d docker-compose down -v Good Luck!
How to access db [Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'#'172.18.0.3' (using password: YES)] in docker container
I have the following docker-compose.yml file. I would like to buildthem and connect to DB version: '3' services: api-server: build: ./api links: - 'db' ports: - '3000:3000' volumes: - ./api:/src - ./src/node_modules tty: true container_name: api-server db: build: context: . dockerfile: ./db/Dockerfile restart: always hostname: db environment: MYSQL_ROOT_PASSWORD: test MYSQL_USER: root MYSQL_PASSWORD: test MYSQL_DATABASE: db volumes: - './db:/config' ports: - 3306:3306 container_name: db After docker-compose build then docker-compose up -d And then `docker exec -it api-server sh' I could enter containers. and tried yarn ts-node node_modules/.bin/typeorm migration:show typeorm command which connect to DB But it returned Error during migration show: Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'#'172.18.0.3' (using password: YES) Are there any way to fix it? Where is the wrong point of it ? Thanks Here is docker logs db docker logs db 2020-09-15 11:57:44+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started. 2020-09-15 11:57:44+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2020-09-15 11:57:44+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started. 2020-09-15 11:57:44+00:00 [Note] [Entrypoint]: Initializing database files 2020-09-15T11:57:44.868762Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2020-09-15T11:57:46.939481Z 0 [Warning] InnoDB: New log files created, LSN=45790 2020-09-15T11:57:47.252278Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2020-09-15T11:57:47.327831Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: abfbf3cb-f74a-11ea-bfe8-0242ac120002. 2020-09-15T11:57:47.331570Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2020-09-15T11:57:48.443477Z 0 [Warning] CA certificate ca.pem is self signed. 2020-09-15T11:57:48.733702Z 1 [Warning] root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. 2020-09-15 11:57:52+00:00 [Note] [Entrypoint]: Database files initialized 2020-09-15 11:57:52+00:00 [Note] [Entrypoint]: Starting temporary server 2020-09-15 11:57:52+00:00 [Note] [Entrypoint]: Waiting for server startup 2020-09-15T11:57:52.490209Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2020-09-15T11:57:52.492212Z 0 [Note] mysqld (mysqld 5.7.31) starting as process 77 ... 2020-09-15T11:57:52.497001Z 0 [Note] InnoDB: PUNCH HOLE support available 2020-09-15T11:57:52.497114Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2020-09-15T11:57:52.497223Z 0 [Note] InnoDB: Uses event mutexes 2020-09-15T11:57:52.497332Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2020-09-15T11:57:52.497452Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11 2020-09-15T11:57:52.497542Z 0 [Note] InnoDB: Using Linux native AIO 2020-09-15T11:57:52.498106Z 0 [Note] InnoDB: Number of pools: 1 2020-09-15T11:57:52.498434Z 0 [Note] InnoDB: Using CPU crc32 instructions 2020-09-15T11:57:52.501015Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2020-09-15T11:57:52.515593Z 0 [Note] InnoDB: Completed initialization of buffer pool 2020-09-15T11:57:52.518852Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2020-09-15T11:57:52.531163Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2020-09-15T11:57:52.555422Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2020-09-15T11:57:52.555698Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2020-09-15T11:57:52.665854Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2020-09-15T11:57:52.667159Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active. 2020-09-15T11:57:52.667286Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 2020-09-15T11:57:52.668320Z 0 [Note] InnoDB: 5.7.31 started; log sequence number 2720554 2020-09-15T11:57:52.669761Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool 2020-09-15T11:57:52.669911Z 0 [Note] Plugin 'FEDERATED' is disabled. 2020-09-15T11:57:52.672485Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200915 11:57:52 2020-09-15T11:57:52.683725Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them. 2020-09-15T11:57:52.683951Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory. 2020-09-15T11:57:52.684864Z 0 [Warning] CA certificate ca.pem is self signed. 2020-09-15T11:57:52.684970Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory. 2020-09-15T11:57:52.687815Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. 2020-09-15T11:57:52.704435Z 0 [Note] Event Scheduler: Loaded 0 events 2020-09-15T11:57:52.705512Z 0 [Note] mysqld: ready for connections. Version: '5.7.31' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server (GPL) 2020-09-15 11:57:53+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. 2020-09-15 11:58:00+00:00 [Note] [Entrypoint]: Creating database mogucare_db 2020-09-15 11:58:00+00:00 [Note] [Entrypoint]: Creating user root ERROR 1396 (HY000) at line 1: Operation CREATE USER failed for 'root'#'%' 2020-09-15 11:58:02+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started. 2020-09-15 11:58:03+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2020-09-15 11:58:03+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started. 2020-09-15T11:58:03.406842Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2020-09-15T11:58:03.409690Z 0 [Note] mysqld (mysqld 5.7.31) starting as process 1 ... 2020-09-15T11:58:03.418038Z 0 [Note] InnoDB: PUNCH HOLE support available 2020-09-15T11:58:03.418101Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2020-09-15T11:58:03.418117Z 0 [Note] InnoDB: Uses event mutexes 2020-09-15T11:58:03.418133Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2020-09-15T11:58:03.418152Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11 2020-09-15T11:58:03.418170Z 0 [Note] InnoDB: Using Linux native AIO 2020-09-15T11:58:03.419647Z 0 [Note] InnoDB: Number of pools: 1 2020-09-15T11:58:03.420784Z 0 [Note] InnoDB: Using CPU crc32 instructions 2020-09-15T11:58:03.425652Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2020-09-15T11:58:03.448462Z 0 [Note] InnoDB: Completed initialization of buffer pool 2020-09-15T11:58:03.457474Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2020-09-15T11:58:03.473399Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2020-09-15T11:58:03.477057Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 2720554 2020-09-15T11:58:03.737975Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 7963136 2020-09-15T11:58:03.934900Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 12578409 2020-09-15T11:58:03.936536Z 0 [Note] InnoDB: Database was not shutdown normally! 2020-09-15T11:58:03.936685Z 0 [Note] InnoDB: Starting crash recovery. 2020-09-15T11:58:04.147681Z 0 [Note] InnoDB: Starting an apply batch of log records to the database... InnoDB: Progress in percent: 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 2020-09-15T11:58:05.179148Z 0 [Note] InnoDB: Apply batch completed 2020-09-15T11:58:05.286743Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1" 2020-09-15T11:58:05.286809Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2020-09-15T11:58:05.286925Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2020-09-15T11:58:05.374586Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2020-09-15T11:58:05.376546Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active. 2020-09-15T11:58:05.377004Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 2020-09-15T11:58:05.378022Z 0 [Note] InnoDB: Waiting for purge to start 2020-09-15T11:58:05.439607Z 0 [Note] InnoDB: 5.7.31 started; log sequence number 12578409 2020-09-15T11:58:05.442005Z 0 [Note] Plugin 'FEDERATED' is disabled. 2020-09-15T11:58:05.454028Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool 2020-09-15T11:58:05.492756Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200915 11:58:05 2020-09-15T11:58:05.518753Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them. 2020-09-15T11:58:05.518785Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory. 2020-09-15T11:58:05.519497Z 0 [Warning] CA certificate ca.pem is self signed. 2020-09-15T11:58:05.519541Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory. 2020-09-15T11:58:05.536601Z 0 [Note] Server hostname (bind-address): '*'; port: 3306 2020-09-15T11:58:05.537666Z 0 [Note] IPv6 is available. 2020-09-15T11:58:05.537947Z 0 [Note] - '::' resolves to '::'; 2020-09-15T11:58:05.538239Z 0 [Note] Server socket created on IP: '::'. 2020-09-15T11:58:05.552491Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. 2020-09-15T11:58:05.574297Z 0 [Note] Event Scheduler: Loaded 0 events 2020-09-15T11:58:05.574997Z 0 [Note] mysqld: ready for connections. Version: '5.7.31' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL) 2020-09-15T11:59:47.472547Z 3 [Note] Access denied for user 'root'#'172.18.0.3' (using password: YES) 2020-09-15T12:03:15.760923Z 4 [Note] Access denied for user 'root'#'172.18.0.3' (using password: YES)
The reason is in MySQL database mysql, table users. The user you are connecting with doesn't have permission - either because it doesn't exist, you have the wrong password, or you have no rights to connect from your IP to the target database. In many cases, MySQL docker containers come configured to only allow connections to localhost (127.0.0.1) which means you must either (a) use port forwarding or (b) grant the user permission to connect from anywhere (i.e. %). Sometimes there is also a configuration switch that will automatically do this for you - read the documentation for your db container.
Unable to start MySQL Server 'has length mismatch in the column name table_name'
I'm trying to run the MySQL Server after importing a big database file 32 GB length mismatch in the column name MySQL 5.7 using rh-mysql57 After using the command to run the server I'm getting a success message saying /etc/init.d/rh-mysql57-mysqld restart Stopping rh-mysql57-mysqld: [ OK ] Starting rh-mysql57-mysqld: [ OK ] The i want to loggin to the mysql using mysql with/without password i'm getting this error ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES) This is the error.log 2019-06-19T13:24:05.489656Z mysqld_safe Starting mysqld daemon with databases from /var/opt/rh/rh-mysql57/lib/mysql 2019-06-19T13:24:05.751511Z 0 [Note] /opt/rh/rh-mysql57/root/usr/libexec/mysqld (mysqld 5.7.24-log) starting as process 19830 ... 2019-06-19T13:24:05.816168Z 0 [Note] InnoDB: PUNCH HOLE support available 2019-06-19T13:24:05.816207Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2019-06-19T13:24:05.816225Z 0 [Note] InnoDB: Uses event mutexes 2019-06-19T13:24:05.816240Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier 2019-06-19T13:24:05.816254Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3 2019-06-19T13:24:05.816268Z 0 [Note] InnoDB: Using Linux native AIO 2019-06-19T13:24:05.818025Z 0 [Note] InnoDB: Number of pools: 1 2019-06-19T13:24:05.818276Z 0 [Note] InnoDB: Not using CPU crc32 instructions 2019-06-19T13:24:05.821067Z 0 [Note] InnoDB: Initializing buffer pool, total size = 2G, instances = 8, chunk size = 128M 2019-06-19T13:24:06.062258Z 0 [Note] InnoDB: Completed initialization of buffer pool 2019-06-19T13:24:06.095072Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2019-06-19T13:24:06.107846Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2019-06-19T13:24:06.275233Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2019-06-19T13:24:06.275514Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2019-06-19T13:24:06.360584Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2019-06-19T13:24:06.362431Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active. 2019-06-19T13:24:06.362460Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 2019-06-19T13:24:06.364052Z 0 [Note] InnoDB: 5.7.24 started; log sequence number 322424549252 2019-06-19T13:24:06.364899Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/opt/rh/rh-mysql57/lib/mysql/ib_buffer_pool 2019-06-19T13:24:06.365282Z 0 [Note] Plugin 'FEDERATED' is disabled. 2019-06-19T13:24:06.366882Z 0 [Note] InnoDB: Buffer pool(s) load completed at 190619 15:24:06 2019-06-19T13:24:06.381320Z 0 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name. Please run mysql_upgrade 2019-06-19T13:24:06.381431Z 0 [Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch in the column name table_name. Please run mysql_upgrade 2019-06-19T13:24:06.387318Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them. 2019-06-19T13:24:06.387370Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory. 2019-06-19T13:24:06.398153Z 0 [Warning] CA certificate ca.pem is self signed. 2019-06-19T13:24:06.398250Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory. 2019-06-19T13:24:06.399654Z 0 [Note] Server hostname (bind-address): '*'; port: 3306 2019-06-19T13:24:06.424466Z 0 [Note] IPv6 is not available. 2019-06-19T13:24:06.424509Z 0 [Note] - '0.0.0.0' resolves to '0.0.0.0'; 2019-06-19T13:24:06.424554Z 0 [Note] Server socket created on IP: '0.0.0.0'. 2019-06-19T13:24:06.436535Z 0 [Note] Failed to start slave threads for channel '' 2019-06-19T13:24:06.449394Z 0 [Note] Event Scheduler: Loaded 0 events 2019-06-19T13:24:06.449666Z 0 [Note] /opt/rh/rh-mysql57/root/usr/libexec/mysqld: ready for connections. Version: '5.7.24-log' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL) 2019-06-19T13:24:07.101293Z 2 [Note] Access denied for user 'UNKNOWN_MYSQL_USER'#'localhost' (using password: NO) 2019-06-19T13:24:36.051422Z 3 [Note] Access denied for user 'root'#'localhost' (using password: YES) The problem as I understand is coming from here 2019-06-19T13:24:06.381320Z 0 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name. Please run mysql_upgrade 2019-06-19T13:24:06.381431Z 0 [Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch in the column name table_name. Please run mysql_upgrade I've tried to run mysql_upgrade and the result is mysql_upgrade: Got error: 1045: Access denied for user 'root'#'localhost' (using password: YES) while connecting to the MySQL server Upgrade process encountered an error and will not continue
The problem was due to an import conflict between MySQL tables from the production server and test server. As the file was large so difficult to modify the contents of the SQL file. So the mysql database was imported too. CAUTION BEFORE PROCESSING PLEASE BACKUP YOUR DATABASE! The solution that worked for us is like the rest 1- Stop the mysql server ref: https://dev.mysql.com/doc/refman/5.7/en/using-systemd.html 2-Added the following parameters to /etc/my.cnf ref: https://dev.mysql.com/doc/refman/5.7/en/system-schema.html innodb_force_recovery = 1 skip-grant-tables 3- In the database directory, save the folder mysql copy themysql folder and empty the contents 4- Then execute the command bin\mysqld --initialize ref: https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization.html 5- At the end execute the command bin\mysql_upgrade ref: https://dev.mysql.com/doc/refman/5.7/en/mysql-upgrade.html 6- Start the mysql server again ref: https://dev.mysql.com/doc/refman/5.7/en/using-systemd.html
I got the same issue & error while working with docker. docker exec -it container_name bash -c "mysql_upgrade -uroot -proot" source: Running mysql_upgrade in Docker?
Docker - MySQL mount/bind with local machine mysql data /var/lib/mysql
i have installed mysql on my local machine and i have docker installed in my machine i am converting my projects to Docker successfully i have deployed flask on container but i want to install mysql on container but mysql container should use my local machine data because data almost 100+Gb in size. I have to do Same for mongodb. Am i missing something for dockerize the existing mysql and mongodb. OS: Ubuntu and default mysql path: /var/lib/mysql I dont want to do import/export. Below is my docker-compose.yml version: "3" services: app: build: context: ./app dockerfile: ./dockerfile container_name: flaskPython links: - mysqldb - mongodb ports: - "5000:5000" myadmin: image: phpmyadmin/phpmyadmin container_name: phpmyadmin ports: - "8282:80" environment: - PMA_ARBITRARY=1 - PMA_HOST=${MYSQL_HOST} restart: always depends_on: - mysqldb - mongodb mysqldb: image: mysql:${MYSQL_VERSION} container_name: ${MYSQL_HOST} restart: 'always' expose: - '3306' env_file: - ".env" environment: - MYSQL_DATABASE=${MYSQL_DATABASE} - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} - MYSQL_USER=${MYSQL_USER} - MYSQL_PASSWORD=${MYSQL_PASSWORD} ports: - "8989:3306" volumes: #- ./data/db/mysql:/var/lib/mysql - /var/lib/mysql:/var/lib/mysql mongodb: image: mongo container_name: mongodb restart: always environment: - MONGO_INITDB_ROOT_USERNAME=root - MONGO_INITDB_ROOT_PASSWORD=root # if you wish to setup additional user accounts specific per DB or with different roles you can use following entry point #no --auth is needed here as presence of username and password add this option automatically command: mongod ports: - "27017:27017" volumes: #- ./data/db/mongo/001_users.js:/docker-entrypoint-initdb.d/001_users.js:ro - ./mongo-entrypoint/:/docker-entrypoint-initdb.d/ - ./data/db/mongo:/usr/data/db Logs: 2019-02-01T16:08:20.100825Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2019-02-01T16:08:20.101919Z 0 [Note] mysqld (mysqld 5.7.22) starting as process 1 ... 2019-02-01T16:08:20.104031Z 0 [Note] InnoDB: PUNCH HOLE support available 2019-02-01T16:08:20.104043Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2019-02-01T16:08:20.104046Z 0 [Note] InnoDB: Uses event mutexes 2019-02-01T16:08:20.104048Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2019-02-01T16:08:20.104050Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3 2019-02-01T16:08:20.104052Z 0 [Note] InnoDB: Using Linux native AIO 2019-02-01T16:08:20.104214Z 0 [Note] InnoDB: Number of pools: 1 2019-02-01T16:08:20.104285Z 0 [Note] InnoDB: Using CPU crc32 instructions 2019-02-01T16:08:20.105476Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2019-02-01T16:08:20.110790Z 0 [Note] InnoDB: Completed initialization of buffer pool 2019-02-01T16:08:20.112288Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2019-02-01T16:08:20.123892Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2019-02-01T16:08:20.139921Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2019-02-01T16:08:20.139996Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2019-02-01T16:08:20.170786Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2019-02-01T16:08:20.173104Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active. 2019-02-01T16:08:20.173143Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 2019-02-01T16:08:20.174483Z 0 [Note] InnoDB: Waiting for purge to start 2019-02-01T16:08:20.224878Z 0 [Note] InnoDB: 5.7.22 started; log sequence number 1529088986 2019-02-01T16:08:20.225403Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool 2019-02-01T16:08:20.225887Z 0 [Note] Plugin 'FEDERATED' is disabled. 2019-02-01T16:08:20.231185Z 0 [Note] InnoDB: Buffer pool(s) load completed at 190201 16:08:20 2019-02-01T16:08:20.233231Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key 2019-02-01T16:08:20.233502Z 0 [Note] Server hostname (bind-address): '*'; port: 3306 2019-02-01T16:08:20.233535Z 0 [Note] IPv6 is available. 2019-02-01T16:08:20.233544Z 0 [Note] - '::' resolves to '::'; 2019-02-01T16:08:20.233556Z 0 [Note] Server socket created on IP: '::'. 2019-02-01T16:08:20.236451Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. 2019-02-01T16:08:20.248740Z 0 [Warning] 'user' entry 'root#localhost' ignored in --skip-name-resolve mode. 2019-02-01T16:08:20.248832Z 0 [Warning] 'user' entry 'mysql.session#localhost' ignored in --skip-name-resolve mode. 2019-02-01T16:08:20.248857Z 0 [Warning] 'user' entry 'mysql.sys#localhost' ignored in --skip-name-resolve mode. 2019-02-01T16:08:20.248875Z 0 [Warning] 'user' entry 'debian-sys-maint#localhost' ignored in --skip-name-resolve mode. 2019-02-01T16:08:20.248921Z 0 [Warning] 'db' entry 'performance_schema mysql.session#localhost' ignored in --skip-name-resolve mode. 2019-02-01T16:08:20.248935Z 0 [Warning] 'db' entry 'sys mysql.sys#localhost' ignored in --skip-name-resolve mode. 2019-02-01T16:08:20.249216Z 0 [Warning] 'proxies_priv' entry '# root#localhost' ignored in --skip-name-resolve mode. 2019-02-01T16:08:20.256300Z 0 [Warning] 'tables_priv' entry 'user mysql.session#localhost' ignored in --skip-name-resolve mode. 2019-02-01T16:08:20.256349Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys#localhost' ignored in --skip-name-resolve mode. 2019-02-01T16:08:20.301149Z 0 [Note] Event Scheduler: Loaded 0 events 2019-02-01T16:08:20.301811Z 0 [Note] mysqld: ready for connections. Version: '5.7.22' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL) I want to use machine mysql data in mysql container so that i dont have to migrate 100+ gb data to mysql container, so that my mysql container will use my local machine mysql data for read and write purpose. PS: i just want i dont migrate machine mysql data to mysql container so that my mysql container somehow link to my machine and use my local machine installed mysql data folder.
Reset MySQL root password not working
I've setup MySQL on my mac a while ago and I forgot what my root password was.(there are only a few password combinations I use, and none of them seems to work) I've tried many methods, including trying to reset the root password in safe mode. Nothing seems to be working for me. Below is the log that I got from a few solutions I tried: 1.Normal Login Yorks-MacBook-Pro:~ yorkwang$ mysql -u root ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO) Yorks-MacBook-Pro:~ yorkwang$ mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'#'localhost' (usingpassword: YES) 2.Safemode Password Reset Yorks-MacBook-Pro:~ yorkwang$ mysqld_safe --skip-grant-tables 2016-07-08T18:37:50.6NZ mysqld_safe Logging to '/usr/local/var/mysql/Yorks-MacBook-Pro.local.err'. 2016-07-08T18:37:51.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql /usr/local/bin/mysqld_safe: line 135: /usr/local/var/mysql/Yorks-MacBook-Pro.local.err: Permission denied rm: /tmp/mysql.sock: Permission denied /usr/local/bin/mysqld_safe: line 169: /usr/local/var/mysql/Yorks-MacBook-Pro.local.err: Permission denied 2016-07-08T18:37:51.6NZ mysqld_safe mysqld from pid file /usr/local/var/mysql/Yorks-MacBook-Pro.local.pid ended /usr/local/bin/mysqld_safe: line 135: /usr/local/var/mysql/Yorks-MacBook-Pro.local.err: Permission denied 3.Safemode Password Reset (with MYSQL server turned off) [1]+ Stopped sudo mysqld --skip-grant-tables Yorks-MacBook-Pro:~ yorkwang$ 2016-07-08T18:43:50.807384Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-07-08T18:43:50.809064Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path. 2016-07-08T18:43:50.810163Z 0 [Note] mysqld (mysqld 5.7.11) starting as process 68112 ... 2016-07-08T18:43:50.823374Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive 2016-07-08T18:43:50.835814Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2016-07-08T18:43:50.835842Z 0 [Note] InnoDB: Uses event mutexes 2016-07-08T18:43:50.835848Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2016-07-08T18:43:50.835852Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3 2016-07-08T18:43:50.837573Z 0 [Note] InnoDB: Number of pools: 1 2016-07-08T18:43:50.839941Z 0 [Note] InnoDB: Using CPU crc32 instructions 2016-07-08T18:43:50.850947Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2016-07-08T18:43:50.865025Z 0 [Note] InnoDB: Completed initialization of buffer pool 2016-07-08T18:43:50.891791Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2016-07-08T18:43:50.926530Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2016-07-08T18:43:50.926759Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2016-07-08T18:43:50.958427Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2016-07-08T18:43:50.959275Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active. 2016-07-08T18:43:50.959287Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 2016-07-08T18:43:50.959505Z 0 [Note] InnoDB: Waiting for purge to start 2016-07-08T18:43:51.014726Z 0 [Note] InnoDB: 5.7.11 started; log sequence number 2494670 2016-07-08T18:43:51.015106Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/var/mysql/ib_buffer_pool 2016-07-08T18:43:51.015947Z 0 [Note] Plugin 'FEDERATED' is disabled. 2016-07-08T18:43:51.029570Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them. 2016-07-08T18:43:51.029602Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory. 2016-07-08T18:43:51.031297Z 0 [Note] InnoDB: Buffer pool(s) load completed at 160708 11:43:51 2016-07-08T18:43:51.033667Z 0 [Warning] CA certificate ca.pem is self signed. 2016-07-08T18:43:51.034667Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory. 2016-07-08T18:43:51.041311Z 0 [Note] Server hostname (bind-address): '*'; port: 3306 2016-07-08T18:43:51.041463Z 0 [Note] IPv6 is available. 2016-07-08T18:43:51.041482Z 0 [Note] - '::' resolves to '::'; 2016-07-08T18:43:51.041495Z 0 [Note] Server socket created on IP: '::'. 2016-07-08T18:43:51.149448Z 0 [Note] mysqld: ready for connections. Version: '5.7.11' socket: '/tmp/mysql.sock' port: 3306 Homebrew mysql -u root mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) Additional info: I'm using a macbook pro with OSX 10.11.5
When you are trying to start the MySQL server without the grant tables, you're receiving (multiple) Permission Denied. For instance, /usr/local/bin/mysqld_safe: line 135: /usr/local/var/mysql/Yorks-MacBook-Pro.local.err: Permission denied and that's why you're being unable to connect to the server (it never had the chance to start). So, first of all, kill any mysqld_safe that might be already running (as super user): $ sudo killall -TERM mysqld_safe; sleep 5; sudo killall -TERM mysqld Check if the process is dead: $ ps -ef | grep mysql If not, and if you don't care about losing database integrity (possible data loss) issue the commands: $ sudo killall -KILL mysqld_safe; sleep 5; sudo killall -KILL mysqld Then, try to start the mysqld_safe with super user privileges (note the --skip-grant-tables): $ sudo mysqld_safe --skip-grant-tables Then connect to the MySQL Server (avoiding the use of the mysql unix socket): $ mysql -uroot -h 127.0.0.1 --protocol=tcp And then, under the MySQL Console: mysql> ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass'; mysql> ALTER USER 'root'#'127.0.0.1' IDENTIFIED BY 'MyNewPass'; References: B.5.3.2 How to Reset the Root Password