ubantu下安装mysql
1 apt-get update
2 sudo apt-get install mysql-server
3 apt-get isntall mysql-client
4 sudo apt-get install libmysqlclient-dev
允许外网访问
1)mysql -u root -p
2)use mysql;
3)允许所有主机:
grant all privileges on *.* to root@"%" identified by "你的密码" with grant option;
4)允许指定主机:
grant all privileges on *.* to root@"192.168.11.205" identified by "你的密码" with grant option;
5)flush privileges;
6) 进mysql库查看host为%的数据是否添加:use mysql; select * from user;
假如完成以上情况还是无法连接,可以去/etc/mysql/mysql.conf.d/mysqld.cnf中查看一下。msyql默认的bind-address是127.0.0.1 这样mysql只能接受localhost的访问,将其改成0.0.0.0就可以了(或者直接注销)然后重启mysql服务service mysql start
导入数据库指南:
①登录:
mysql -u root -p 然后输入密码(root)
②创建数据库:
create database demo_sfabric;
③选择数据库:
use demo_sfabric;
④设置外键忽略(如果不忽略外键会导入失败)
set foreign_key_checks=0;
⑤导入数据库
source /data/www/sfabric.sql;