Mac uninstall mysql and reinstall mysql

1. Mac uninstall mysql

1. Find the MySQL service in System Preferences -> Stop
insert image description here
2. Open the terminal

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
vim /etc/hostconfig and removed the line MYSQLCOM=-YES-rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*

3. The uninstallation success icon disappears
and the uninstallation is complete

2. Reinstall mysql

Download the MySQL installation package
If you haven’t downloaded it yet, please go to the official website to download it;
link: https://dev.mysql.com/downloads/mysql/
insert image description here
If you don’t know whether your computer is ARM or X86, you can open the terminal and enter: uname -a to view;
it is X86 Just download the X86, 64-bit version.
insert image description here
2. Install MySQL
Double-click the downloaded dmg installation package to install
Next, next,
enter the password: (remember)
insert image description here
3. Configure MySQL
to open the Mac terminal connection, enter mysql
to edit the .zshrc configuration file through vim on the terminal

sudo vim ~/.zshrc 

After opening, press the i key to enter the edit mode, and add the following in the configuration file:

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

Then press the esc key to exit the editing mode, enter: wq ! to exit and save
, and then execute source ~/.zshrc to make the environment variable configuration take effect

source ~/.zshrc

3. Solve the problem that navicat cannot connect

1. The prompt to connect to mysql with navicat is as follows:
2059 - Authentication plugin 'caching_sha2_password' cannot be loaded: dlope

2. Solution

The reason for this is that the encryption rule in versions before mysql 8 is mysql_native_password, and after mysql8, the encryption rule is caching_sha2_password. There are two ways to solve the problem, one is to upgrade the navicat driver, and the other is to restore the mysql user login password encryption rule into mysql_native_password.
1. Run the command prompt with administrator privileges and log in to MySql

mysql -u root -p

2. Modify account password encryption rules and update user passwords

ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;   #修改加密规则 
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';   #更新一下用户的密码 

You can reset your password again

alter user 'root'@'localhost' identified by '123456';

Prompt that the connection is successful.

Guess you like

Origin blog.csdn.net/weixin_43401243/article/details/128398795