Search code examples
databasemariadbxamppwindows-11

Unable to Initialize and Start MySQL in XAMPP on Windows 11 - Can't Connect to MySQL Server (10061)


I'm trying to set up MySQL on XAMPP on my Windows 11 machine, but I'm encountering persistent issues that I can't resolve. Here is a detailed account of what I've done and the errors I'm seeing.

  1. Stopped XAMPP Services:

    • I used the XAMPP Control Panel to stop Apache and MySQL services.
    • Verified no mysqld processes were running using Task Manager.
  2. Removed Existing MySQL Data Directory:

    • Command:
      cd C:\xampp\mysql
      rmdir /S /Q data
      mkdir data
      
  3. Initialized a New MySQL Data Directory:

    • Command:
      cd bin
      mysqld --initialize-insecure --datadir=C:/xampp/mysql/data
      
  4. Attempted to Connect to MySQL:

    • Command:
      mysql -u root
      
    • Error received:
      ERROR 2002 (HY000): Can't connect to MySQL server on 'localhost' (10061)
      

Additional Information:

  • Windows Version: Windows 11 Home 64-bit
  • XAMPP Version: 8.2.12
  • Control Panel Version: 3.3.0 (Compiled: Apr 6th 2021)
  • MySQL Version: MariaDB 10.4.32 (bundled with XAMPP)

MySQL Error Log (relevant entries):

2024-06-13 14:25:15 0 [Note] Starting MariaDB 10.4.32-MariaDB-log source revision c4143f909528e3fab0677a28631d10389354c491 as process 7140
2024-06-13 14:25:15 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2024-06-13 14:25:15 0 [Note] InnoDB: Uses event mutexes
2024-06-13 14:25:15 0 [Note] InnoDB: Compressed tables use zlib 1.3
2024-06-13 14:25:15 0 [Note] InnoDB: Number of pools: 1
2024-06-13 14:25:15 0 [Note] InnoDB: Using SSE2 crc32 instructions
2024-06-13 14:25:15 0 [Note] InnoDB: Initializing buffer pool, total size = 64M, instances = 1, chunk size = 64M
2024-06-13 14:25:15 0 [Note] InnoDB: Completed initialization of buffer pool
2024-06-13 14:25:15 0 [Note] InnoDB: Resizing redo log from 2*50331648 to 2*16777216 bytes; LSN=47056
2024-06-13 14:25:15 0 [Note] InnoDB: Starting to delete and rewrite log files.
2024-06-13 14:25:15 0 [Note] InnoDB: Setting log file C:\xampp\mysql\data\ib_logfile101 size to 16777216 bytes
2024-06-13 14:25:15 0 [Note] InnoDB: Setting log file C:\xampp\mysql\data\ib_logfile1 size to 16777216 bytes
2024-06-13 14:25:15 0 [Note] InnoDB: Renaming log file C:\xampp\mysql\data\ib_logfile101 to C:\xampp\mysql\data\ib_logfile0
2024-06-13 14:25:15 0 [Note] InnoDB: New log files created, LSN=47056
2024-06-13 14:25:15 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2024-06-13 14:25:15 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2024-06-13 14:25:15 0 [Note] InnoDB: Setting file 'C:\xampp\mysql\data\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2024-06-13 14:25:15 0 [Note] InnoDB: File 'C:\xampp\mysql\data\ibtmp1' size is now 12 MB.
2024-06-13 14:25:15 0 [Note] InnoDB: Waiting for purge to start
2024-06-13 14:25:15 0 [Note] InnoDB: 10.4.32 started; log sequence number 47056; transaction id 8
2024-06-13 14:25:15 0 [Note] InnoDB: Loading buffer pool(s) from C:\xampp\mysql\data\ib_buffer_pool
2024-06-13 14:25:15 0 [Note] Plugin 'FEEDBACK' is disabled.
2024-06-13 14:25:15 0 [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
2024-06-13 14:25:15 0 [Note] InnoDB: Buffer pool(s) load completed at 240613 14:25:15
2024-06-13 14:25:15 6 [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 1017: Can't find file: '.\mysql\' (errno: 2 "No such file or directory")
2024-06-13 14:25:15 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
2024-06-13 14:25:15 0 [Note] Server socket created on IP: '0.0.0.0'.

Attempts to Fix:

  • Removed and recreated the data directory.
  • Ran mysqld --initialize-insecure --datadir=C:/xampp/mysql/data.
  • Error persists when trying to connect to MySQL using mysql -u root.

What can I do to successfully initialize and start MySQL in XAMPP on my Windows 11 machine? Any help would be greatly appreciated.


Solution

  • --initialize-insecure only installs the innodb stuff but not the system tables. Therefore the server claims about missing mysql directory:

    1017: Can't find file: '.\mysql\' (errno: 2 "No such file or directory")
    

    Use mariadb_install_db command instead, as described in the Documentation