Ubuntu16.04如何安装MySQL5.7?
安装主程序
主程序安装就我知道有两种方式:
- 使用apt-get全自动安装
# 安装命令apt-get install mysql-server# 安装过程中需要输入mysql的root密码 |
使用dpkg手动安装依赖包
# 1. 下载安装包# 我测试过程中下载的是:mysql-server_5.7.16-1ubuntu16.04_amd64.deb-bundle.tar# 国内镜像站:http://mirrors.sohu.com/mysql/MySQL-5.7/wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-server_5.7.16-1ubuntu16.04_amd64.deb-bundle.tar# 2. 解压安装包# 解压后将出现:# libmysqlclient20_5.7.16-1ubuntu16.04_amd64.deb# mysql-common_5.7.16-1ubuntu16.04_amd64.deb # mysql-community-source_5.7.16-1ubuntu16.04_amd64.deb # mysql-testsuite_5.7.16-1ubuntu16.04_amd64.deb# libmysqlclient-dev_5.7.16-1ubuntu16.04_amd64.deb # mysql-community_5.7.16-1ubuntu16.04_amd64.changes # mysql-community-test_5.7.16-1ubuntu16.04_amd64.deb # libmysqld-dev_5.7.16-1ubuntu16.04_amd64.deb # mysql-community-client_5.7.16-1ubuntu16.04_amd64.deb # mysql-server_5.7.16-1ubuntu16.04_amd64.deb# mysql-client_5.7.16-1ubuntu16.04_amd64.deb # mysql-community-server_5.7.16-1ubuntu16.04_amd64.debtar -xvf ../mysql-server_5.7.16-1ubuntu16.04_amd64.deb-bundle.tar -C ./# 3. 使用dpkg安装依赖包dpkg -i mysql-common_5.7.16-1ubuntu16.04_amd64.debdpkg -i libmysqlclient20_5.7.17-1ubuntu16.04_amd64.deb dpkg -i libmysqlclient-dev_5.7.17-1ubuntu16.04_amd64.deb dpkg -i libmysqld-dev_5.7.17-1ubuntu16.04_amd64.deb# 上面四个包安装应该都没有什么问题,接下来安装的包将会抛出缺少依赖包的错误# 所缺包名当时搞忘了记下来,请仔细看一下错误信息,然后使用apt-get安装一下即可dpkg -i mysql-community-client_5.7.17-1ubuntu16.04_amd64.deb dpkg -i mysql-client_5.7.17-1ubuntu16.04_amd64.deb dpkg -i mysql-community-source_5.7.17-1ubuntu16.04_amd64.deb# 接下来我们需要安装mysql-community-server包了,安装之前还需要按照一个依赖包:libmecab2apt-get install libmecab2dpkg -i mysql-community-server_5.7.17-1ubuntu16.04_amd64.deb ## 安装过程中需要输入mysql的root密码 |
至此,我们已经完成了主程序安装,并可以在本机使用MySQL -u root -p进行登录数据库了。
开放远程访问
开启root用户的全称访问权限
1、修改数据库中user的host
sh # 使用mysql -u root -p登录到数据库,然后依次执行下面语句 # xxxxxx表示root用户的密码 use mysql; update user set host = '%' where user ='root'; grant all privileges on *.* to 'root'@'%' identified by 'xxxxxx'; flush privileges; |
2、修改my.conf的中的ip绑定
sh # 进入编辑/etc/mysql/mysql.conf.d/mysqld.conf vi /etc/mysql/mysql.conf.d/mysqld.conf # 修改ip绑定 # 源文件中为: bind-address 127.0.0.1 # 将其修改为: bind-address 0.0.0.0 # 覆盖保存 esc:wq |