由于某些原因,又要在ubuntu系统中安装mysql了,之前曾经安装过好多次。都没记下来

以前一直动用源码包来安装,基于两个原因:1.一直用Python写代码。2.想使用文件来安装,而不是通过api

 

这次使用deb-bundle包

1.下载包:

下载地址为:

http://115.156.188.226/cdn.mysql.com//Downloads/MySQL-5.6/mysql-server_5.6.28-1ubuntu14.04_amd64.deb-bundle.tar

2.将包上传至服务器,并将该文件解压

解压命令为:

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

3.安装文件

这里这些文件存在着依赖关系,如果一个一个安装,要安装顺序来安装:

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-server_5.6.28-1ubuntu14.04_amd64.deb 

  到这里个人认为服务器应该可以使用了(未测试),但是mysql命令还不能使用

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的安装完成

还有几个文件没有用,用处现在不知道

mysql-community-bench_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-testsuite_5.6.28-1ubuntu14.04_amd64.deb

4.启动和停止mysql服务命令

/etc/init.d/mysql start
/etc/init.d/mysql stop

 

5.mysql安装之后,使用户可以从其它地址可以访问服务器

首先得修改/etc/mysql/my.cnf文件,将

bind-address    = 127.0.0.1

修改为

bind-address    = 0.0.0.0


然后得创建远程访问的用户,并赋予其访问权限
  创建用户并且赋予权限,实际上有好几种方法。这里使用我个人最喜欢的方式,一部到位,需要进入到mysql之后执行命令

脚本如下:

GRANT <ALL|priv1,priv2,.....privn> 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;
posted on 2015-12-11 17:45  苍老的鱼  阅读(11440)  评论(0编辑  收藏  举报