Detailed steps for installing MySQL database
The steps to install the MySQL database are as follows:
- Download the MySQL installation package by visiting the official MySQL website (https://www.mysql.com/) and clicking on the “Downloads” menu to select the suitable version for your operating system.
- Unzip the installation package: Extract the downloaded installation package to a specified directory (for example: C:\mysql).
- Set up MySQL: Go into the directory where the files were extracted, create a new my.ini file, and use it to configure MySQL’s parameters. Add the following content to the my.ini file:
-
[mysqld]
basedir=installation directory
datadir=directory for storing database files
port=port number
character-set-server=utf8 - Replace “installation directory” with the actual directory path where MySQL is installed, replace “database file storage directory” with the directory path where MySQL database files are stored, and replace “port number” with the port number used by MySQL.
- To initialize the database, open the command line window, go to the bin directory where MySQL is extracted (for example: C:\mysql\bin), and execute the following command to initialize the MySQL database.
- Initialize the MySQL database and display the process in the console.
- After completion, a random initial password will be generated.
- Start the MySQL service by executing the following command.
- Start MySQL in console mode.
- To run the service in the background, you can use the following command to start the service:
- Install the MySQL service and start it.
- Log in to MySQL: Use the following command to access the MySQL database:
- Login to MySQL as root user.
- Simply enter the initial password to login successfully.
- Change password: After successfully logging in, use the following command to change your password:
- Change the password for the user ‘root’@’localhost’ to a new one.
- Replace “new password” with your own new password.
The installation of the MySQL database is now complete.