解压下载的压缩包
tar –xvf mysql-server_5.6.28-1ubuntu14.04_amd64.deb-bundle.tar
解压后得到一系列的.deb文件。依次为:
libmysqlclient18_5.6.28-1ubuntu14.04_amd64.deb
libmysqlclient-dev_5.6.28-1ubuntu14.04_amd64.deb
libmysqld-dev_5.6.28-1ubuntu14.04_amd64.deb
mysql-client_5.6.28-1ubuntu14.04_amd64.deb
mysql-common_5.6.28-1ubuntu14.04_amd64.deb
mysql-community-bench_5.6.28-1ubuntu14.04_amd64.deb
mysql-community-client_5.6.28-1ubuntu14.04_amd64.deb
mysql-community-server_5.6.28-1ubuntu14.04_amd64.deb
mysql-community-source_5.6.28-1ubuntu14.04_amd64.deb
mysql-community-test_5.6.28-1ubuntu14.04_amd64.deb
mysql-server_5.6.28-1ubuntu14.04_amd64.deb
mysql-testsuite_5.6.28-1ubuntu14.04_amd64.deb
安装文件
这里这些文件存在着依赖关系,如果一个一个安装,要安装顺序来安装:
sudo dpkg -i mysql-common_5.6.28-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqlclient18_5.6.28-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqlclient-dev_5.6.28-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqld-dev_5.6.28-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-community-server_5.6.28-1ubuntu14.04_amd64.deb
注意:在安装mysql-community-server会要求输入root账户密码
sudo dpkg -i mysql-community-client_5.6.28-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-client_5.6.28-1ubuntu14.04_amd64.deb
到这里,mysql的安装完成
注意:如果在安装上述deb中出现依赖包没有安装,请使用apt-get install 进行安装
启动mysql服务命令
/etc/init.d/mysql start
mysql安装之后,使用户可以从其它地址可以访问服务器
首先得修改/etc/mysql/my.cnf文件,将
bind-address = 127.0.0.1
修改为
bind-address = 0.0.0.0
然后得创建远程访问的用户,并赋予其访问权限
创建用户并且赋予权限,实际上有好几种方法。这里使用我个人最喜欢的方式,一部到位,需要进入到mysql之后执行命令。
脚本如下:
GRANT ON
[object] [IDENTIFIED BY 'password']
[WITH GRANT OPTION];
MAX_QUERIES_PER_HOUR count
MAX_UPDATES_PER_HOUR count
MAX_CONNECTIONS_PER_HOUR count
MAX_USER_CONNECTIONS count
说明:priv代表权限select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14个权限
示例:
grant select,insert,update,delete,create,drop on test.hr to john@192.168.10.1 identified by '123';
表示为用户john创建从地址192.168.10.1对数据库test的hr表进行select,insert,update,delete,create,drop的权限,其密码为123
grant select,insert,update,delete,create,drop on *.* to john@'%' identified by '123';
表示为用户john创建从任何远程地址对数据库的所有库和表进行select,insert,update,delete,create,drop的权限,其密码为123
执行完后需要刷新权限:
flush privileges;