Can u help me about this error

Jan 02 08:27:20 intranet-bdam systemd[1]: Starting MySQL Community Server…
Jan 02 08:27:20 intranet-bdam su[270317]: (to mysql) root on none
Jan 02 08:27:20 intranet-bdam su[270317]: pam_unix(su-l:session): session opened for user mysql by (uid=0)
Jan 02 08:27:20 intranet-bdam mysql-systemd-start[270282]: 2023-01-02T08:27:20.790509Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server
Jan 02 08:27:20 intranet-bdam mysql-systemd-start[270282]: 2023-01-02T08:27:20.791120Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
Jan 02 08:27:20 intranet-bdam mysql-systemd-start[270282]: 2023-01-02T08:27:20.791130Z 0 [ERROR] Aborting
Jan 02 08:27:20 intranet-bdam su[270317]: pam_unix(su-l:session): session closed for user mysql
Jan 02 08:27:23 intranet-bdam mysqld[270358]: Initialization of mysqld failed: 0
Jan 02 08:27:23 intranet-bdam systemd[1]: mysql.service: Control process exited, code=exited, status=1/FAILURE

2 Likes

Hi @omadd

Could you verify that specified data folder is empty? An existing data directory is permitted to be nonempty if every entry has a name that begins with a period (. ).

2 Likes

Hi @omadd,

Thanks for reaching out. From the logs, it seems that you are trying to launch a new MySQL server on the machine where MySQL was previously installed or some directory is already present there. Can you explain what are you trying to do or if you are trying to install mysql, then remove this directory or create a new one and try again. Let us know and will be happy to help you.

1 Like
  • Check the Data Directory: Access the MySQL data directory and check if there are any files present in the directory. This error often occurs when the data directory isn’t empty during an initialization or re-initialization process.
  • Backup Data (if necessary): If you’re okay with removing existing data in the data directory, ensure you have backups of any crucial data before proceeding.
  • Remove Existing Data (if applicable): If you’re fine with removing existing data, clear the contents of the MySQL data directory using the following command (ensure to replace [data_directory] with your actual MySQL data directory path):
  • bash
  • Copy code

sudo rm -rf [data_directory]/*

  • Reinitialize MySQL: Try to reinitialize the MySQL server. You can use the --initialize option during the MySQL server startup. Make sure to include the appropriate configuration and paths according to your MySQL setup.
  • bash
  • Copy code

sudo mysqld --initialize --explicit_defaults_for_timestamp=1 --datadir=[data_directory]

  • Start MySQL Service: Once the reinitialization is successful, start the MySQL service.
  • bash
  • Copy code

sudo systemctl start mysql

  • Check MySQL Status: Confirm the status of the MySQL service to ensure it is running without any issues.
  • bash
  • Copy code

sudo systemctl status mysql

By following these steps, you should be able to address the issues related to the MySQL server initialization and get the service up and running properly. If you encounter any other errors or issues, it might be beneficial to review the MySQL error log for more specific details on the problem.