mysql password after installation

WBOY
Release: 2023-05-20 09:42:07
Original
1201 people have browsed it

MySQL is an open source relational database management system that is widely used in application development, data analysis, business intelligence and other fields. After installing MySQL, set a secure password to protect the security of the database.

In this article, we will introduce how to install MySQL and how to set a password after installation.

Step one: Download and install MySQL

  1. Enter the MySQL official website (https://www.mysql.com/) and click the "Downloads" tab.
  2. In the "MySQL Community Downloads" page, select the version suitable for your operating system and click the "Download" button.
  3. After the download is completed, install MySQL according to the system prompts.

Step 2: Set the root password of MySQL

  1. Open the terminal (command line under Windows) and log in to MySQL with root privileges. Enter the following command to enter MySQL:

    $ mysql -u root -p

    You need to enter an empty password when logging in for the first time, just press Enter.

  2. Set the password for the root user

    In the MySQL command line, enter the following command:

    mysql> SET PASSWORD FOR 'root'@'localhost ' = PASSWORD('new_password_here');

    Among them, "new_password_here" is the password you want to set. Note that the password must contain numbers, uppercase and lowercase letters, and special characters, and be no less than 8 characters in length.

    If you cannot change the password due to permission issues, you can enter the following command first:

    mysql> UPDATE mysql.user SET authentication_string = PASSWORD('new_password_here') WHERE user = 'root' AND host = 'localhost';

    mysql> FLUSH PRIVILEGES;

    Then enter the previous command to successfully change the password.

  3. Exit MySQL

    Enter the following command to exit the MySQL command line:

    mysql> exit

    If you need to enter MySQL later, you can Use the following command:

    $ mysql -u root -p

    Then enter the password you set.

Summary:

After installing MySQL, we need to set a secure root user password to ensure the security of the database. This password can be changed from the MySQL command line. Please ensure that the password you set is secure enough and do not leak it to others.

The above is the detailed content of mysql password after installation. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!