mysql: install

installation

  1. Download the mysql installation package
    Insert picture description here

  2. installation
    Insert picture description here

  3. Configuration

    • Configure Mysql Server password policy
      • use strong password encryption, use strong password encryption. mysql8 supports a stronger authentication method based on SHA256, which is recommended for all newly installed mysql server. Clients or connectors cannot connect to this mysql server if they do not support this method. ☑️
      • use legacy password encryption, use old password encryption.
    • Configure root password: a reasonable password rule is: at least 8 characters, including numbers, letters, and other characters
  4. Check
    Open "System Preferences" and find that mysql server has been installed: it is
    Insert picture description here
    already running.
    Insert picture description here

  5. Connect the terminal to the mysql server to
    open the terminal, and append the MySQL bin directory to the Path:

PATH="$PATH":/usr/local/mysql/bin

Then log in to MySQL through the following command

mysql -u root -p

If you like to change the password:

set PASSWORD =PASSWORD('123456');
  1. Experience mysql in the terminal to
    view the database, the default is as follows:
    Insert picture description here
    use the database, such as mysql:
    Insert picture description here
    view the table under the database:
    Insert picture description here
    print the table structure:
desc default_roles;
  1. It is recommended to install mysql GUI (visual tool)
    Insert picture description here
    DBeaver for free.

Forgot root password

  1. Enter the configuration page, close the service "stop mysql server"
    Insert picture description here
  2. Enter the terminal
cd /usr/local/mysql/bin/

Login as administrator

sudo su

Enter the following command to disable mysql authentication function

./mysqld_safe --skip-grant-tables &

After pressing Enter, mysql will automatically restart and become running

  1. Set password
    Enter the command:
./mysql

Enter the command again

FLUSH PRIVILEGES

Then enter the command:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('你的新密码');

The new password is set successfully!

Guess you like

Origin blog.csdn.net/u010682774/article/details/113123876