ubuntu安装mysql5.7教程
参考资料
MySQL5.7参考手册[MySQL 5.7 Reference Manual]
通过Debain安装包安装MySQL [Installing MySQL on Linux Using Debain Packages from Oracle]
下载MySQL5.7 [Download MySQL-5.7 Community Server]
安装步骤
1. 下载MySQL debain安装包
进入下载MySQL5.7 [Download MySQL-5.7 Community Server]下载页面下载MySQL安装包,在下载列表中选择DEB Bundle项,下载到本地的文件为tar压缩包,如mysql-server_5.7.24-1ubuntu14.04_amd64.deb-bundle.tar。
注意事项
需要在MySQL下载页面的下载选项处选择如下三项版本信息:
1. mysql版本, 比如5.7.24
2. 选择操作系统类型, 比如Ubuntu Linux
3. 选择操作系统版本, 比如Ubuntu Linux 14.04(x86, 64-bit)
操作截图
2. 安装MySQL
解压下载的tar包
比如下载的tar包存放在 /F/dev_tools/目录下, 则在终端中进入该目录,使用如下命令进行压缩包解压
shell> cd /F/dev_tools/
shell> tar -zxvf mysql-server_5.7.24-1ubuntu14.04_amd64.deb-bundle.tar
解压后会在/F/dev_tools/目录下生成一个mysql-server_5.7.24-1ubuntu14.04_amd64.deb-bundle目录,解压后的文件列表如下:
libmysqlclient20_5.7.24-1ubuntu14.04_amd64.deb
libmysqlclient-dev_5.7.24-1ubuntu14.04_amd64.deb
libmysqld-dev_5.7.24-1ubuntu14.04_amd64.deb
mysql-client_5.7.24-1ubuntu14.04_amd64.deb
mysql-common_5.7.24-1ubuntu14.04_amd64.deb
mysql-community-client_5.7.24-1ubuntu14.04_amd64.deb
mysql-community-server_5.7.24-1ubuntu14.04_amd64.deb
mysql-community-source_5.7.24-1ubuntu14.04_amd64.deb
mysql-community-test_5.7.24-1ubuntu14.04_amd64.deb
mysql-server_5.7.24-1ubuntu14.04_amd64.deb
mysql-testsuite_5.7.24-1ubuntu14.04_amd64.deb
3. 安装libaio支持库
如果已安装则可以跳过该步骤
安装命令
shell> sudo apt-get install libaio1
4. MySQL预配置
这一步是用来预先配置MySQL root用户的密码的,可能还会有其他安装MySQL过程中需要配置的信息。
操作命令
shell> cd /F/dev_tools/mysql-server_5.7.24-1ubuntu14.04_amd64.deb-bundle
shell> sudo dpkg-preconfigure mysql-community-server_*.deb
5. 安装MySQL
关于MySQL5.7, MySQL官方教程提供了非常方便的安装指令,进入MySQL deb安装包所在目录,执行如下命令即可完成MySQL安装。
shell> cd /F/dev_tools/mysql-server_5.7.24-1ubuntu14.04_amd64.deb-bundle
shell> sudo dpkg -i mysql-{common,community-client,client,community-server,server}_*.deb
在安装过程中可能会出现如下问题:
dpkg: dependency problems prevent configuration of mysql-community-server:
mysql-community-server depends on libmecab2 (>= 0.996-1.2ubuntu1); however:
Package libmecab2 is not installed.
dpkg: error processing package mysql-community-server (--install):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-community-server (=5.7.24-1ubuntu14.04); however:
Package mysql-community-server is not configured yet.
dpkg: error processing package mysql-server (--install):
dependency problems - leaving unconfigured.
……
执行如下命令即可解决
shell> sudo apt-get install libmecab2
6. 安装完成之后的文件位置
- 所有配置文件( 如my.cnf )都在 /etc/mysql 目录下
- 所有二进制文件、支持库、头文件等都存放在 /usr/bin 和 /usr/sbin 目录下
- 数据文件存放在 /var/lib/mysql 目录下