Forget the root password;
①Close the service:
sudo service mysql stop;
②Safe mode + authentication-free startup service
sudo /usr/local/mysql/ bin/mysqld_safe --skip-grant-tables
①Open a new terminal and connect to the server:
Open a new terminal:
②Switch to mysql database: mysql -u root
use mysql;
③Change password
update user set password = password('123456') where user='root'; span>
< p>
4. Allow all ip access:
GRANT ALL PRIVILEGES ON *.* TO’root’@’%’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;