mysql 5.7.17 安装配置方法图文教程(ubuntu 16.04)

 更新时间:2017年01月18日 09:07:34   作者:_supernatural  
这篇文章主要为大家分享了ubuntu 16.04下mysql 5.7.17 安装配置方法图文教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

在MySQL官网上下载最新版的Ubuntu Linux专用的MySQL。我这里下载的是:

mysql-server_5.7.17-1ubuntu16.04_amd64.deb-bundle.tar

也可从以下mirrors下载:

http://mirrors.sohu.com/mysql/MySQL-5.7/

解压文件 命令为:

复制代码 代码如下:
root@ubuntu:/fly/mysql# tar -xvf ../mysql-server_5.7.17-1ubuntu16.04_amd64.deb-bundle.tar -C ./ 

解压开来后,一共有11个deb包,用sudo dpkg -i [包名]命令逐个安装,因为包与包中间存在依赖关系,这里安装有个先后顺序。

-rw-r--r--  1 7155 31415    841472 Nov 28 05:50 libmysqlclient20_5.7.17-1ubuntu16.04_amd64.deb 
-rw-r--r--  1 7155 31415   1189512 Nov 28 05:50 libmysqlclient-dev_5.7.17-1ubuntu16.04_amd64.deb 
-rw-r--r--  1 7155 31415  17383814 Nov 28 05:50 libmysqld-dev_5.7.17-1ubuntu16.04_amd64.deb 
-rw-r--r--  1 7155 31415     12644 Nov 28 05:50 mysql-client_5.7.17-1ubuntu16.04_amd64.deb 
-rw-r--r--  1 7155 31415     71282 Nov 28 05:50 mysql-common_5.7.17-1ubuntu16.04_amd64.deb 
-rw-r--r--  1 7155 31415      6815 Nov 28 05:50 mysql-community_5.7.17-1ubuntu16.04_amd64.changes 
-rw-r--r--  1 7155 31415   7357222 Nov 28 05:50 mysql-community-client_5.7.17-1ubuntu16.04_amd64.deb 
-rw-r--r--  1 7155 31415  24698654 Nov 28 05:50 mysql-community-server_5.7.17-1ubuntu16.04_amd64.deb 
-rw-r--r--  1 7155 31415 133305884 Nov 28 05:50 mysql-community-source_5.7.17-1ubuntu16.04_amd64.deb 
-rw-r--r--  1 7155 31415  23384678 Nov 28 05:50 mysql-community-test_5.7.17-1ubuntu16.04_amd64.deb 
-rw-r--r--  1 7155 31415     12636 Nov 28 05:50 mysql-server_5.7.17-1ubuntu16.04_amd64.deb 
-rw-r--r--  1 7155 31415     12652 Nov 28 05:50 mysql-testsuite_5.7.17-1ubuntu16.04_amd64.deb 

我的安装的顺序是:
1.mysql-common_5.7.17-1ubuntu16.04_amd64.deb
2.libmysqlclient20_5.7.17-1ubuntu16.04_amd64.deb
3.libmysqlclient-dev_5.7.17-1ubuntu16.04_amd64.deb
4.libmysqld-dev_5.7.17-1ubuntu16.04_amd64.deb

5.mysql-community-client_5.7.17-1ubuntu16.04_amd64.deb
6.mysql-client_5.7.17-1ubuntu16.04_amd64.deb
7.mysql-community-source_5.7.17-1ubuntu16.04_amd64.deb

这里需要再安装一个依赖包叫libmecab2,安装好后,继续安装最后一个:
8.mysql-community-server_5.7.17-1ubuntu16.04_amd64.deb
安装过程中需要设置数据库密码。
到这里,所有的已经安装完毕。输入Mysql -u root -p可以登陆数据库了。

root@ubuntu:/fly/mysql# dpkg -i mysql-common_5.7.17-1ubuntu16.04_amd64.deb  
dpkg: warning: downgrading mysql-common from 5.7.17-1ubuntu16.10 to 5.7.17-1ubuntu16.04 
(Reading database ... 212644 files and directories currently installed.) 
Preparing to unpack mysql-common_5.7.17-1ubuntu16.04_amd64.deb ... 
Unpacking mysql-common (5.7.17-1ubuntu16.04) over (5.7.17-1ubuntu16.10) ... 
Setting up mysql-common (5.7.17-1ubuntu16.04) ... 
root@ubuntu:/fly/mysql# dpkg -i libmysqlclient20_5.7.17-1ubuntu16.04_amd64.deb  
dpkg: warning: downgrading libmysqlclient20:amd64 from 5.7.17-1ubuntu16.10 to 5.7.17-1ubuntu16.04 
(Reading database ... 212644 files and directories currently installed.) 
Preparing to unpack libmysqlclient20_5.7.17-1ubuntu16.04_amd64.deb ... 
Unpacking libmysqlclient20:amd64 (5.7.17-1ubuntu16.04) over (5.7.17-1ubuntu16.10) ... 
Setting up libmysqlclient20:amd64 (5.7.17-1ubuntu16.04) ... 
Processing triggers for libc-bin (2.23-0ubuntu5) ... 
root@ubuntu:/fly/mysql# dpkg -i libmysqlclient-dev_5.7.17-1ubuntu16.04_amd64.deb  
dpkg: warning: downgrading libmysqlclient-dev from 5.7.17-1ubuntu16.10 to 5.7.17-1ubuntu16.04 
(Reading database ... 212644 files and directories currently installed.) 
Preparing to unpack libmysqlclient-dev_5.7.17-1ubuntu16.04_amd64.deb ... 
Unpacking libmysqlclient-dev (5.7.17-1ubuntu16.04) over (5.7.17-1ubuntu16.10) ... 
Setting up libmysqlclient-dev (5.7.17-1ubuntu16.04) ... 
Processing triggers for man-db (2.7.5-1) ... 
root@ubuntu:/fly/mysql# dpkg -i libmysqld-dev_5.7.17-1ubuntu16.04_amd64.deb  
dpkg: warning: downgrading libmysqld-dev from 5.7.17-1ubuntu16.10 to 5.7.17-1ubuntu16.04 
(Reading database ... 212644 files and directories currently installed.) 
Preparing to unpack libmysqld-dev_5.7.17-1ubuntu16.04_amd64.deb ... 
Unpacking libmysqld-dev (5.7.17-1ubuntu16.04) over (5.7.17-1ubuntu16.10) ... 
Setting up libmysqld-dev (5.7.17-1ubuntu16.04) ... 
root@ubuntu:/fly/mysql# dpkg -i mysql-community-client_5.7.17-1ubuntu16.04_amd64.deb  
dpkg: warning: downgrading mysql-community-client from 5.7.17-1ubuntu16.10 to 5.7.17-1ubuntu16.04 
(Reading database ... 212644 files and directories currently installed.) 
Preparing to unpack mysql-community-client_5.7.17-1ubuntu16.04_amd64.deb ... 
Unpacking mysql-community-client (5.7.17-1ubuntu16.04) over (5.7.17-1ubuntu16.10) ... 
Setting up mysql-community-client (5.7.17-1ubuntu16.04) ... 
Processing triggers for man-db (2.7.5-1) ... 
root@ubuntu:/fly/mysql# dpkg -i mysql-client_5.7.17-1ubuntu16.04_amd64.deb  
dpkg: warning: downgrading mysql-client from 5.7.17-1ubuntu16.10 to 5.7.17-1ubuntu16.04 
(Reading database ... 212644 files and directories currently installed.) 
Preparing to unpack mysql-client_5.7.17-1ubuntu16.04_amd64.deb ... 
Unpacking mysql-client (5.7.17-1ubuntu16.04) over (5.7.17-1ubuntu16.10) ... 
Setting up mysql-client (5.7.17-1ubuntu16.04) ... 
root@ubuntu:/fly/mysql# dpkg -i mysql-community-source_5.7.17-1ubuntu16.04_amd64.deb  
dpkg: warning: downgrading mysql-community-source from 5.7.17-1ubuntu16.10 to 5.7.17-1ubuntu16.04 
(Reading database ... 212644 files and directories currently installed.) 
Preparing to unpack mysql-community-source_5.7.17-1ubuntu16.04_amd64.deb ... 
Unpacking mysql-community-source (5.7.17-1ubuntu16.04) over (5.7.17-1ubuntu16.10) ... 
Setting up mysql-community-source (5.7.17-1ubuntu16.04) ... 
root@ubuntu:/fly/mysql# dpkg -i mysql-community-server_5.7.17-1ubuntu16.04_amd64.deb  
Selecting previously unselected package mysql-community-server. 
(Reading database ... 212644 files and directories currently installed.) 
Preparing to unpack mysql-community-server_5.7.17-1ubuntu16.04_amd64.deb ... 
Unpacking mysql-community-server (5.7.17-1ubuntu16.04) ... 
Setting up mysql-community-server (5.7.17-1ubuntu16.04) ... 
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode 
Processing triggers for systemd (229-4ubuntu13) ... 
Processing triggers for ureadahead (0.100.0-19) ... 
Processing triggers for man-db (2.7.5-1) ... 
root@ubuntu:/fly/mysql# mysql -u root -p 
Enter password:  
Welcome to the MySQL monitor.  Commands end with ; or \g. 
Your MySQL connection id is 3 
Server version: 5.7.17 MySQL Community Server (GPL) 
 
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. 
 
Oracle is a registered trademark of Oracle Corporation and/or its 
affiliates. Other names may be trademarks of their respective 
owners. 
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 
mysql> 

mysql简单安装方式:

1. sudo apt-get install mysql-server

2. apt-get isntall mysql-client

3.  sudo apt-get install libmysqlclient-dev

安装过程中会提示设置密码什么的,注意设置了不要忘了,安装完成之后可以使用如下命令来检查是否安装成功:

sudo netstat -tap | grep mysql

通过上述命令检查之后,如果看到有mysql 的socket处于 listen 状态则表示安装成功。

登陆mysql数据库可以通过如下命令:

mysql -u root -p

-u 表示选择登陆的用户名, -p 表示登陆的用户密码,上面命令输入之后会提示输入密码,此时输入密码就可以登录到mysql。

然后通过 show databases; 就可以查看当前的数据库。

我们选择 mysql数据库就行下一步操作,使用use mysql 命令,显示当前数据库的表单:show tables

mysql下如何执行sql脚本

mysql> create database mydatabase; 
Query OK, 1 row affected (0.00 sec) 
 
mysql> use mydatabase; 
Database changed 
mysql> source ./mysql.sql 
Query OK, 0 rows affected, 1 warning (0.00 sec) 
Query OK, 0 rows affected (0.00 sec) 
Query OK, 0 rows affected (0.33 sec) 
Records: 0 Duplicates: 0 Warnings: 0 
Query OK, 0 rows affected, 1 warning (0.00 sec) 
Query OK, 0 rows affected (0.00 sec) 
Query OK, 0 rows affected, 1 warning (0.00 sec) 
Query OK, 0 rows affected (0.04 sec) 
Query OK, 0 rows affected, 1 warning (0.00 sec) 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> show tables; 

dpkg安装出现的问题:

安装mysql server时产生软件依赖问题:
mysql-community-server depends on apparmor; however:
Package apparmor is not installed.
mysql-community-server depends on libmecab2 (>= 0.996-1.2ubuntu1); however:
Package libmecab2 is not installed.
那就先安装上:
sudo apt -get install libmecab2
然后mysql-community-server,mysql-server就能正常使用了

在ubuntu下安装任何软件都提示以下错误:

You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 kate : Depends: kdelibs4c2a (>= 4:3.5.9) but it is not going to be installed
        Depends: libqt3-mt (>= 3:3.3.8b) but it is not going to be installed
        Recommends: kregexpeditor but it is not installable
 kscope : Depends: kdelibs4c2a (>= 4:3.5.7-1) but it is not going to be installed
          Depends: libaudio2 but it is not going to be installed
          Depends: libqt3-mt (>= 3:3.3.8really3.3.7) but it is not going to be installed
          Depends: cscope but it is not going to be installed
          Depends: exuberant-ctags but it is not going to be installed
          Depends: graphviz but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

解决方法:

     删除提示的kate和kscope两个未完全安装的软件。

 $sudo dpkg --purge kate
 $sudo dpkg --purge kscope

精彩专题分享:mysql不同版本安装教程 mysql5.7各版本安装教程 mysql5.6各版本安装教程

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

相关文章

  • mysql允许远程连接的方法

    mysql允许远程连接的方法

    这篇文章主要介绍了mysql允许远程连接的方法,内容很详细,感兴趣的小伙伴们可以参考一下
    2015-12-12
  • MySQL对数据库操作(创建、选择、删除)

    MySQL对数据库操作(创建、选择、删除)

    这篇文章主要介绍了MySQL如何对数据库操作,文中讲解非常详细,代码帮助大家更好的理解和学习,感兴趣的朋友可以了解下
    2020-07-07
  • MySQL8.0.11安装总结教程图解

    MySQL8.0.11安装总结教程图解

    本文通过图文并茂的形式给大家介绍了MySQL8.0.11安装总结,非常不错,具有参考借鉴价值,需要的朋友参考下吧
    2018-05-05
  • MySQL查询优化:连接查询排序浅谈

    MySQL查询优化:连接查询排序浅谈

    不知道有没有人碰到过这样恶心的问题:两张表连接查询并limit,SQL效率很高,但是加上order by以后,语句的执行时间变的巨长,效率巨低。下边就来看看这个问题需要如何解决
    2013-02-02
  • 深入sql数据连接时的一些问题分析

    深入sql数据连接时的一些问题分析

    本篇文章是对关于sql数据连接时的一些问题进行了详细的分析介绍,需要的朋友参考下
    2013-06-06
  • 使用FriendFeed来提升MySQL性能的方法

    使用FriendFeed来提升MySQL性能的方法

    这篇文章主要介绍了使用FriendFeed来提升MySQL性能的方法,用其来存储无模式的数据从而能够维护索引,需要的朋友可以参考下
    2015-06-06
  • MYSQL锁表问题的解决方法

    MYSQL锁表问题的解决方法

    这篇文章主要介绍了MYSQL锁表问题的解决方法,结合实例形式分析了MySQL锁表问题的常见情况与相应解决方法,需要的朋友可以参考下
    2016-03-03
  • CentOS Linux更改MySQL数据库目录位置具体操作

    CentOS Linux更改MySQL数据库目录位置具体操作

    由于MySQL的数据库太大,默认安装的/var盘已经再也无法容纳新增加的数据,没有办法,只能想办法转移数据的目录,本文整理了一些MySQL从/var/lib/mysql目录下面转移到/home/mysql_data/mysql目录的具体操作,感兴趣的你可不要走开啊
    2013-01-01
  • 微信昵称带符号导致插入MySQL数据库时出错的解决方案

    微信昵称带符号导致插入MySQL数据库时出错的解决方案

    Mysql的utf8编码最多3个字节,而Emoji表情或者某些特殊字符是4个字节,所以会导致带有表情的昵称插入数据库时出错,下面给大家分享下解决方案,需要的朋友参考下吧
    2016-12-12
  • MySQL导出所有Index和约束的方法

    MySQL导出所有Index和约束的方法

    这篇文章主要介绍了MySQL导出所有Index和约束的方法,非常实用的技巧,需要的朋友可以参考下
    2014-08-08

最新评论