更新软件包列表:sudo apt update
安装mysql软件包:sudo apt install mysql-server
登录mysql服务:mysql -u admin -p
退出命令行:control+D
查看版本:SELECT VERSION();
查找配置IP、端口文件位置:
sudo find /etc/mysql/ -name “*.cnf” -exec grep -H “bind-address” {} +
配置链接主机IP:
bind-address =0.0.0.0
mysqlx-bind-address = 0.0.0.0
port:端口(不可重复)
查看mysql链接状态:
sudo systemctl status mysql
关闭启动服务:
sudo systemctl start/stop mysql
查看进程:ps aux | grep mysql
查看IP和端口是否被禁用:netstat -tuln | grep :
创建新用户赋予所有IP均可访问权限:
CREATE USER ‘admin’@‘%’ IDENTIFIED BY ‘your_password’;
GRANT ALL PRIVILEGES ON . TO ‘admin’@‘%’ WITH GRANT OPTION;
刷新列表:
FLUSH PRIVILEGES
navicat:
主机IP = 服务器IP
用户名 = admin
密码 = your_password