Why uninstall, 1. Forgot root password, 2. MySQL Server has been unable to connect. terminal execution.
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo 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.*
mysql install
Download from the official website . Community -> MySQL Community Server. Pull down and select the system to download directly.
The .dmg file is installed foolishly, and a pop-up box for the root password will pop up at the end. Be sure to copy the password, copy the password, and copy the password. Otherwise, uninstall-install again.
A temporary password is generated for root@localhost: 8pK.fSfp#QhK
After the installation is complete: Preferences->Bottom->mysql->start the server.
Terminal: , Enter the mysqlroot user and enter the password below. , Enter the password, after reinstallation, the initial password is the password to be copied and saved above. mysql -u root -p
Enter password:
After entering mysql, you can change the password to the password you remember.
mysql> set password = password('新密码')
Create a new user and set a password create user 'lfpython'@'localhost' identified by 'lfpython'
Create a data table create database testDB;
Authorize the user to have all permissions on the database: grant all privileges on pytest.* to lfpython@localhost identified by 'lfpython'