Open the terminal in the virtual machine and enter the command
ifconfig
Enter the command in the terminal (the configuration file may have a slightly different path due to different versions)
sudo vim /etc/mysql/conf.d/mysql.cnf
Type "i" to start editing, modify bind-address = 0.0.0.0 (set to be accessible externally, If set to 127.0.0.1, it can only be accessed locally.)
esc key to exit editing, enter ":wq" to save and exit.
Then log in to MySQL to change permissions
mysql - uroot -p GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'passwrd' WITH GRANT OPTION; FLUSH PRIVILEGES; # 退出登录MySQL exit; # 重启服务器 service mysql restart
Supplement: Navicat connects to mysql in the virtual machine
The following sql means to add permissions to the root user whose password is 000000
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '000000' WITH GRANT OPTION;
Navicat connects to the mysql command line
The above is the detailed content of How to implement the mysql operation of navicat connecting to Ubuntu virtual machine. For more information, please follow other related articles on the PHP Chinese website!