mysql 5.7.17 安裝配置方法圖文教程(ubuntu 16.04)
在MySQL官網(wǎng)上下載最新版的Ubuntu Linux專用的MySQL。我這里下載的是:
mysql-server_5.7.17-1ubuntu16.04_amd64.deb-bundle.tar
也可從以下mirrors下載:
http://mirrors.sohu.com/mysql/MySQL-5.7/
解壓文件 命令為:
解壓開來后,一共有11個(gè)deb包,用sudo dpkg -i [包名]命令逐個(gè)安裝,因?yàn)榘c包中間存在依賴關(guān)系,這里安裝有個(gè)先后順序。
-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
這里需要再安裝一個(gè)依賴包叫libmecab2,安裝好后,繼續(xù)安裝最后一個(gè):
8.mysql-community-server_5.7.17-1ubuntu16.04_amd64.deb
安裝過程中需要設(shè)置數(shù)據(jù)庫(kù)密碼。
到這里,所有的已經(jīng)安裝完畢。輸入Mysql -u root -p可以登陸數(shù)據(jù)庫(kù)了。
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簡(jiǎn)單安裝方式:
1. sudo apt-get install mysql-server
2. apt-get isntall mysql-client
3. sudo apt-get install libmysqlclient-dev
安裝過程中會(huì)提示設(shè)置密碼什么的,注意設(shè)置了不要忘了,安裝完成之后可以使用如下命令來檢查是否安裝成功:
sudo netstat -tap | grep mysql
通過上述命令檢查之后,如果看到有mysql 的socket處于 listen 狀態(tài)則表示安裝成功。
登陸mysql數(shù)據(jù)庫(kù)可以通過如下命令:
mysql -u root -p
-u 表示選擇登陸的用戶名, -p 表示登陸的用戶密碼,上面命令輸入之后會(huì)提示輸入密碼,此時(shí)輸入密碼就可以登錄到mysql。
然后通過 show databases; 就可以查看當(dāng)前的數(shù)據(jù)庫(kù)。
我們選擇 mysql數(shù)據(jù)庫(kù)就行下一步操作,使用use mysql 命令,顯示當(dāng)前數(shù)據(jù)庫(kù)的表單:show tables
mysql下如何執(zhí)行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安裝出現(xiàn)的問題:
安裝mysql server時(shí)產(chǎn)生軟件依賴問題:
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下安裝任何軟件都提示以下錯(cuò)誤:
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兩個(gè)未完全安裝的軟件。
$sudo dpkg --purge kate $sudo dpkg --purge kscope
精彩專題分享:mysql不同版本安裝教程 mysql5.7各版本安裝教程 mysql5.6各版本安裝教程
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
mysql 強(qiáng)大的trim() 函數(shù)
這篇文章主要介紹了mysql 強(qiáng)大的trim() 函數(shù)使用方法,需要的朋友可以參考下2014-03-03
MYSQL數(shù)據(jù)庫(kù)基礎(chǔ)之Join操作原理
這篇文章主要給大家介紹了關(guān)于MYSQL數(shù)據(jù)庫(kù)基礎(chǔ)之Join操作原理的相關(guān)資料,連接(join)查詢是將兩個(gè)查詢的結(jié)果以“橫向?qū)印钡姆绞胶喜⑵饋淼慕Y(jié)果,需要的朋友可以參考下2021-07-07
逐步講解MySQL中定時(shí)事件計(jì)劃的創(chuàng)建
這篇文章主要介紹了MySQL中定時(shí)事件計(jì)劃的創(chuàng)建,包括對(duì)于MySQL定時(shí)器的用戶事件權(quán)限作出了解釋說明,需要的朋友可以參考下2016-05-05
MySQL中實(shí)現(xiàn)動(dòng)態(tài)表單中JSON元素精準(zhǔn)匹配的方法示例
本文主要介紹了MySQL中實(shí)現(xiàn)動(dòng)態(tài)表單中JSON元素精準(zhǔn)匹配的方法示例,重點(diǎn)講解如何在將設(shè)計(jì)好的動(dòng)態(tài)表單信息進(jìn)行提取,具有一定的參考價(jià)值,感興趣的可以了解一下2024-07-07

