首先下载ubuntu 12.04 64位对应的myqsl版本 http://dev.mysql.com/downloads/file/?id=464508
然后按照如下步骤即可
http://blog.csdn.net/q894523017/article/details/50705392
1、安装 mysql
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libaio1
--不要使用下面语句装
(apt-get install mysql-server mysql-client自动安装会装上5.5)
sudo groupadd mysql
sudo useradd -r -g mysql mysql
cd /usr/local/src
sudo wget mysql-server_5.7.10-1ubuntu14.04_amd64.deb-bundle.tar http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-server_5.7.10-1ubuntu14.04_amd64.deb-bundle.tar
sudo chmod +x mysql-server_5.7.10-1ubuntu14.04_amd64.deb-bundle.tar
tar -xf mysql-server_5.7.10-1ubuntu14.04_amd64.deb-bundle.tar
ps:会解压出以下文件
libmysqlclient20_5.7.10-1ubuntu14.04_amd64.deb
libmysqlclient-dev_5.7.10-1ubuntu14.04_amd64.deb
libmysqld-dev_5.7.10-1ubuntu14.04_amd64.deb
mysql-community-client_5.7.10-1ubuntu14.04_amd64.deb
mysql-community-server_5.7.10-1ubuntu14.04_amd64.deb
mysql-community-source_5.7.10-1ubuntu14.04_amd64.deb
mysql-client_5.7.10-1ubuntu14.04_amd64.deb
mysql-community-test_5.7.10-1ubuntu14.04_amd64.deb
mysql-common_5.7.10-1ubuntu14.04_amd64.deb
mysql-server_5.7.10-1ubuntu14.04_amd64.deb
mysql-community_5.7.10-1ubuntu14.04_amd64.changes
mysql-testsuite_5.7.10-1ubuntu14.04_amd64.deb
更新设置到最新系统:
sudo apt-get update
sudo apt-get upgrade
apt-get install libaio1
然后分别安装以下的包:
sudo dpkg -i mysql-common_5.7.10-1ubuntu14.04_amd64.deb
sudo dpkg-preconfigure mysql-community-server_5.7.10-1ubuntu14.04_amd64.deb
此步需要输入数据的root密码
sudo dpkg -i libmysqlclient20_5.7.10-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqlclient-dev_5.7.10-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqld-dev_5.7.10-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-client_5.7.10-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-community-client_5.7.10-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-common_5.7.10-1ubuntu14.04_amd64.deb
sudo apt-get -f install
此步为了安装依赖包 libmecab2
sudo dpkg -i mysql-community-server_5.7.10-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-server_5.7.10-1ubuntu14.04_amd64.deb
这时数据安装完成,并自动启动
查看mysql安装的路径和依赖:
whereis mysql
mysql: /usr/bin/mysql /etc/mysql /usr/lib/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
这时你会发现 mysql以服务形式自启动
这时候在本机可以通过 mysql -r root -p 登录了
2、开启远程访问访问
默认情况下远程访问会出现 Can’t connect to MySQL server on ‘192.168.10.18′ (10061) 错误
是因为,mysql的默认配置为了增强安全性,禁止了非本机的访问,在ubuntu中是这样,debian中也是。禁止的方式以前是在my.cnf中有一句
skip-network
现在则变成了:
# Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 127.0.0.1
就是只监听本机地址。所以,如果要开放局域网内的访问,需要注释掉这一句,或者改成:
bind-address = 0.0.0.0
就行了
# vi /etc/mysql/my.cnf
修改
bind-address = 127.0.0.1 为 bind-address = 0.0.0.0
修改完成后重启mysql服务
# sudo /etc/init.d/mysql restart
这样改完3306端口就开始监听了,但是MYSQL的权限还没有打开ROOT远程登陆
Mysql默认是不允许远程连接的,因为有很大的安全隐患。
需要手动增加可以远程访问数据库的用户。
方法一、本地登入mysql,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,将"localhost"改为"%"
#mysql -u root -proot
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
mysql>FLUSH PRIVILEGES;
修改完这些就可以远程访问了。
3、mysql数据库重启命令
启动:sudo /etc/init.d/mysql start
停止:sudo /etc/init.d/mysql stop
重启:sudo /etc/init.d/mysql restart