mysql 5.7.17 安装配置方法图文教程(ubuntu 16.04)
在MySQL官网上下载最新版的UbuntuLinux专用的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包,用sudodpkg-i[包名]命令逐个安装,因为包与包中间存在依赖关系,这里安装有个先后顺序。
-rw-r--r-- 1715531415 841472Nov2805:50libmysqlclient20_5.7.17-1ubuntu16.04_amd64.deb
-rw-r--r-- 1715531415 1189512Nov2805:50libmysqlclient-dev_5.7.17-1ubuntu16.04_amd64.deb
-rw-r--r-- 1715531415 17383814Nov2805:50libmysqld-dev_5.7.17-1ubuntu16.04_amd64.deb
-rw-r--r-- 1715531415 12644Nov2805:50mysql-client_5.7.17-1ubuntu16.04_amd64.deb
-rw-r--r-- 1715531415 71282Nov2805:50mysql-common_5.7.17-1ubuntu16.04_amd64.deb
-rw-r--r-- 1715531415 6815Nov2805:50mysql-community_5.7.17-1ubuntu16.04_amd64.changes
-rw-r--r-- 1715531415 7357222Nov2805:50mysql-community-client_5.7.17-1ubuntu16.04_amd64.deb
-rw-r--r-- 1715531415 24698654Nov2805:50mysql-community-server_5.7.17-1ubuntu16.04_amd64.deb
-rw-r--r-- 1715531415133305884Nov2805:50mysql-community-source_5.7.17-1ubuntu16.04_amd64.deb
-rw-r--r-- 1715531415 23384678Nov2805:50mysql-community-test_5.7.17-1ubuntu16.04_amd64.deb
-rw-r--r-- 1715531415 12636Nov2805:50mysql-server_5.7.17-1ubuntu16.04_amd64.deb
-rw-r--r-- 1715531415 12652Nov2805:50mysql-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-uroot-p可以登陆数据库了。
root@ubuntu:/fly/mysql#dpkg-imysql-common_5.7.17-1ubuntu16.04_amd64.deb
dpkg:warning:downgradingmysql-commonfrom5.7.17-1ubuntu16.10to5.7.17-1ubuntu16.04
(Readingdatabase...212644filesanddirectoriescurrentlyinstalled.)
Preparingtounpackmysql-common_5.7.17-1ubuntu16.04_amd64.deb...
Unpackingmysql-common(5.7.17-1ubuntu16.04)over(5.7.17-1ubuntu16.10)...
Settingupmysql-common(5.7.17-1ubuntu16.04)...
root@ubuntu:/fly/mysql#dpkg-ilibmysqlclient20_5.7.17-1ubuntu16.04_amd64.deb
dpkg:warning:downgradinglibmysqlclient20:amd64from5.7.17-1ubuntu16.10to5.7.17-1ubuntu16.04
(Readingdatabase...212644filesanddirectoriescurrentlyinstalled.)
Preparingtounpacklibmysqlclient20_5.7.17-1ubuntu16.04_amd64.deb...
Unpackinglibmysqlclient20:amd64(5.7.17-1ubuntu16.04)over(5.7.17-1ubuntu16.10)...
Settinguplibmysqlclient20:amd64(5.7.17-1ubuntu16.04)...
Processingtriggersforlibc-bin(2.23-0ubuntu5)...
root@ubuntu:/fly/mysql#dpkg-ilibmysqlclient-dev_5.7.17-1ubuntu16.04_amd64.deb
dpkg:warning:downgradinglibmysqlclient-devfrom5.7.17-1ubuntu16.10to5.7.17-1ubuntu16.04
(Readingdatabase...212644filesanddirectoriescurrentlyinstalled.)
Preparingtounpacklibmysqlclient-dev_5.7.17-1ubuntu16.04_amd64.deb...
Unpackinglibmysqlclient-dev(5.7.17-1ubuntu16.04)over(5.7.17-1ubuntu16.10)...
Settinguplibmysqlclient-dev(5.7.17-1ubuntu16.04)...
Processingtriggersforman-db(2.7.5-1)...
root@ubuntu:/fly/mysql#dpkg-ilibmysqld-dev_5.7.17-1ubuntu16.04_amd64.deb
dpkg:warning:downgradinglibmysqld-devfrom5.7.17-1ubuntu16.10to5.7.17-1ubuntu16.04
(Readingdatabase...212644filesanddirectoriescurrentlyinstalled.)
Preparingtounpacklibmysqld-dev_5.7.17-1ubuntu16.04_amd64.deb...
Unpackinglibmysqld-dev(5.7.17-1ubuntu16.04)over(5.7.17-1ubuntu16.10)...
Settinguplibmysqld-dev(5.7.17-1ubuntu16.04)...
root@ubuntu:/fly/mysql#dpkg-imysql-community-client_5.7.17-1ubuntu16.04_amd64.deb
dpkg:warning:downgradingmysql-community-clientfrom5.7.17-1ubuntu16.10to5.7.17-1ubuntu16.04
(Readingdatabase...212644filesanddirectoriescurrentlyinstalled.)
Preparingtounpackmysql-community-client_5.7.17-1ubuntu16.04_amd64.deb...
Unpackingmysql-community-client(5.7.17-1ubuntu16.04)over(5.7.17-1ubuntu16.10)...
Settingupmysql-community-client(5.7.17-1ubuntu16.04)...
Processingtriggersforman-db(2.7.5-1)...
root@ubuntu:/fly/mysql#dpkg-imysql-client_5.7.17-1ubuntu16.04_amd64.deb
dpkg:warning:downgradingmysql-clientfrom5.7.17-1ubuntu16.10to5.7.17-1ubuntu16.04
(Readingdatabase...212644filesanddirectoriescurrentlyinstalled.)
Preparingtounpackmysql-client_5.7.17-1ubuntu16.04_amd64.deb...
Unpackingmysql-client(5.7.17-1ubuntu16.04)over(5.7.17-1ubuntu16.10)...
Settingupmysql-client(5.7.17-1ubuntu16.04)...
root@ubuntu:/fly/mysql#dpkg-imysql-community-source_5.7.17-1ubuntu16.04_amd64.deb
dpkg:warning:downgradingmysql-community-sourcefrom5.7.17-1ubuntu16.10to5.7.17-1ubuntu16.04
(Readingdatabase...212644filesanddirectoriescurrentlyinstalled.)
Preparingtounpackmysql-community-source_5.7.17-1ubuntu16.04_amd64.deb...
Unpackingmysql-community-source(5.7.17-1ubuntu16.04)over(5.7.17-1ubuntu16.10)...
Settingupmysql-community-source(5.7.17-1ubuntu16.04)...
root@ubuntu:/fly/mysql#dpkg-imysql-community-server_5.7.17-1ubuntu16.04_amd64.deb
Selectingpreviouslyunselectedpackagemysql-community-server.
(Readingdatabase...212644filesanddirectoriescurrentlyinstalled.)
Preparingtounpackmysql-community-server_5.7.17-1ubuntu16.04_amd64.deb...
Unpackingmysql-community-server(5.7.17-1ubuntu16.04)...
Settingupmysql-community-server(5.7.17-1ubuntu16.04)...
update-alternatives:using/etc/mysql/mysql.cnftoprovide/etc/mysql/my.cnf(my.cnf)inautomode
Processingtriggersforsystemd(229-4ubuntu13)...
Processingtriggersforureadahead(0.100.0-19)...
Processingtriggersforman-db(2.7.5-1)...
root@ubuntu:/fly/mysql#mysql-uroot-p
Enterpassword:
WelcometotheMySQLmonitor. Commandsendwith;or\g.
YourMySQLconnectionidis3
Serverversion:5.7.17MySQLCommunityServer(GPL)
Copyright(c)2000,2016,Oracleand/oritsaffiliates.Allrightsreserved.
OracleisaregisteredtrademarkofOracleCorporationand/orits
affiliates.Othernamesmaybetrademarksoftheirrespective
owners.
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
mysql>
mysql简单安装方式:
1.sudoapt-getinstallmysql-server
2.apt-getisntallmysql-client
3. sudoapt-getinstalllibmysqlclient-dev
安装过程中会提示设置密码什么的,注意设置了不要忘了,安装完成之后可以使用如下命令来检查是否安装成功:
sudonetstat-tap|grepmysql
通过上述命令检查之后,如果看到有mysql的socket处于listen状态则表示安装成功。
登陆mysql数据库可以通过如下命令:
mysql-uroot-p
-u表示选择登陆的用户名,-p表示登陆的用户密码,上面命令输入之后会提示输入密码,此时输入密码就可以登录到mysql。
然后通过showdatabases;就可以查看当前的数据库。
我们选择mysql数据库就行下一步操作,使用usemysql命令,显示当前数据库的表单:showtables
mysql下如何执行sql脚本
mysql>createdatabasemydatabase; QueryOK,1rowaffected(0.00sec) mysql>usemydatabase; Databasechanged mysql>source./mysql.sql QueryOK,0rowsaffected,1warning(0.00sec) QueryOK,0rowsaffected(0.00sec) QueryOK,0rowsaffected(0.33sec) Records:0Duplicates:0Warnings:0 QueryOK,0rowsaffected,1warning(0.00sec) QueryOK,0rowsaffected(0.00sec) QueryOK,0rowsaffected,1warning(0.00sec) QueryOK,0rowsaffected(0.04sec) QueryOK,0rowsaffected,1warning(0.00sec) QueryOK,0rowsaffected(0.00sec) mysql>showtables;
dpkg安装出现的问题:
安装mysqlserver时产生软件依赖问题:
mysql-community-serverdependsonapparmor;however:
Packageapparmorisnotinstalled.
mysql-community-serverdependsonlibmecab2(>=0.996-1.2ubuntu1);however:
Packagelibmecab2isnotinstalled.
那就先安装上:
sudoapt-getinstalllibmecab2
然后mysql-community-server,mysql-server就能正常使用了
在ubuntu下安装任何软件都提示以下错误:
Youmightwanttorun'apt-get-finstall'tocorrectthese:
Thefollowingpackageshaveunmetdependencies:
kate:Depends:kdelibs4c2a(>=4:3.5.9)butitisnotgoingtobeinstalled
Depends:libqt3-mt(>=3:3.3.8b)butitisnotgoingtobeinstalled
Recommends:kregexpeditorbutitisnotinstallable
kscope:Depends:kdelibs4c2a(>=4:3.5.7-1)butitisnotgoingtobeinstalled
Depends:libaudio2butitisnotgoingtobeinstalled
Depends:libqt3-mt(>=3:3.3.8really3.3.7)butitisnotgoingtobeinstalled
Depends:cscopebutitisnotgoingtobeinstalled
Depends:exuberant-ctagsbutitisnotgoingtobeinstalled
Depends:graphvizbutitisnotgoingtobeinstalled
E:Unmetdependencies.Try'apt-get-finstall'withnopackages(orspecifyasolution).
解决方法:
删除提示的kate和kscope两个未完全安装的软件。
$sudodpkg--purgekate $sudodpkg--purgekscope
精彩专题分享:mysql不同版本安装教程mysql5.7各版本安装教程mysql5.6各版本安装教程
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。