sudo apt-get install mysql 然后按俩下tab
sudo apt-get install mysql-server-5.6
安装完成后,我的执行apt-get install mysql-server-5.6
默认就把client安装好了,如果没有安装client,那就自己执行apt-get install mysql-client-5.6
关于Mysql命令:
检查MySQL的状态:sudo service mysql status
开启MySQL服务器:sudo service mysql start
关闭MySQL服务器:sudo service mysql stop
查看mysql进程:ps -ef | grep mysql
mysql 授权远程登录数据库:
1. 首先我们要切换到mysql系统数据库:mysql -uroot -ppassword
(root为root的用户名,password为root的密码)
2.grant all privileges on *.* to '用户名'@'%' identified by '密码' with grant option;
3.刷新权限:flush privileges;
4.退出数据库:exit;
开启端口:
修改配置文件
mysql-5.7:vi /etc/mysql/mysql.conf.d/mysqld.cnf
mysql-5.6:vi /etc/mysql/my.cnf
将bind-address = 127.0.0.1
注释掉,
重启mysql服务:service mysql restart
远程连接:
sudo ufw allow 80/tcp
sudo ufw delete allow 80/tcp
sudo ufw allow smtp
sudo ufw delete allow smtp
sudo ufw allow from 192.168.0.1
sudo ufw delete allow from 192.168.0.1