Initialize mysql in Windows and mysql in windows

Source: Internet
Author: User

Initialize mysql in Windows and mysql in windows

In Linux, after mysql is installed, the service cannot be started directly. You must initialize the database first. Initialization mainly includes:

  • Initialize required files for logs, tablespaces, and other databases;
  • Create and initialize the system database (mysql ).
After initialization, start the mysqld daemon to access the database. In Windows, the installation package contains an initialized environment, which is displayed in the data subdirectory of the mysql root directory. Therefore, manual Initialization is not required. However, in some cases, you may need to initialize the database from scratch, for example:
  • Data files are damaged and need to be rebuilt;
  • We hope to keep the existing environment unchanged and create a new environment;
  • We hope to build a clean environment.
Unfortunately, in Linux, The mysql_install_db.sh script is used to initialize the database environment. In windows, the script is not provided. So what should we do? After analyzing mysql_install_db.sh in Linux, we found that the commands used to initialize the database are mainly the following:
mysql_install_db.sh# Pipe mysql_system_tables.sql to "mysqld --bootstrap"s_echo "Installing MySQL system tables..."if { echo "use mysql;"; cat $create_system_tables $fill_system_tables; } | eval "$filter_cmd_line" | $mysqld_install_cmd_line > /dev/nullthen  s_echo "OK"  s_echo "Filling help tables..."  # Pipe fill_help_tables.sql to "mysqld --bootstrap"  if { echo "use mysql;"; cat $fill_help_tables; } | $mysqld_install_cmd_line > /dev/null  then    s_echo "OK"......

  

Where:
  • $ Create_system_tables, $ fill_system_tables, and $ fill_help_tables are used to create a system database, initialize data in the system database, and initialize help data;
  • $ Filter_cmd_line is used to filter out the Host Name (for cross-initialization of non-local running database environments, which can be ignored );
  • $ Mysqld_install_cmd_line is mainly the "mysqld -- bootstrap" command;
After analyzing the above content, you can manually initialize the database. The procedure is as follows: the database has been initialized and can be accessed normally.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.