Ubuntu 14.04下MySQL服務器和客戶端的安裝

如今的軟件愈來愈好安裝,尤爲是在ubuntu下安裝軟件,更是沒有技巧,只須要在聯網的狀況下使用apt-get inatll 便可。在決定安裝mysql以前,要先肯定系統是否已經安裝mysql。html

hadoop@master:~$ netstat -tap | grep mysql 
(並不是全部進程都能被檢測到,全部非本用戶的進程信息將不會顯示,若是想看到全部信息,則必須切換到 root 用戶)

由此能夠看出系統中並無安裝mysql,執行如下命令進行安裝。mysql

hadoop@master:~$ sudo apt-get install mysql-server 
正在讀取軟件包列表... 完成 
正在分析軟件包的依賴關係樹 
正在讀取狀態信息... 完成 
將會安裝下列額外的軟件包: 
libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18 
libterm-readkey-perl mysql-client-5.5 mysql-common mysql-server-5.5 
mysql-server-core-5.5 
建議安裝的軟件包: 
libmldbm-perl libnet-daemon-perl libplrpc-perl libsql-statement-perl 
libipc-sharedcache-perl tinyca mailx 
下列【新】軟件包將被安裝: 
libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18 
libterm-readkey-perl mysql-client-5.5 mysql-common mysql-server 
mysql-server-5.5 mysql-server-core-5.5 
升級了 0 個軟件包,新安裝了 10 個軟件包,要卸載 0 個軟件包,有 158 個軟件包未被升級。 
須要下載 8,343 kB 的軟件包。 
解壓縮後會消耗掉 86.8 MB 的額外空間。 
您但願繼續執行嗎? [Y/n]  
sudo apt-get install mysql-server

 

輸入Y進入到安裝界面,在安裝過程當中,會彈出一個界面要求輸入mysql的root的密碼,這裏必定輸入,免得安裝後再設密碼了。linux

 

  再次輸入密碼:sql

 

獲取:1 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-common all 5.5.38-0ubuntu0.14.04.1 [14.1 kB] 
獲取:2 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libmysqlclient18 i386 5.5.38-0ubuntu0.14.04.1 [592 kB] 
獲取:3 http://us.archive.ubuntu.com/ubuntu/ trusty/main libdbi-perl i386 1.630-1 [881 kB] 
獲取:4 http://us.archive.ubuntu.com/ubuntu/ trusty/main libdbd-mysql-perl i386 4.025-1 [99.6 kB] 
獲取:5 http://us.archive.ubuntu.com/ubuntu/ trusty/main libterm-readkey-perl i386 2.31-1 [27.2 kB] 
獲取:6 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-client-5.5 i386 5.5.38-0ubuntu0.14.04.1 [1,433 kB] 
獲取:7 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server-core-5.5 i386 5.5.38-0ubuntu0.14.04.1 [3,135 kB] 
獲取:8 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server-5.5 i386 5.5.38-0ubuntu0.14.04.1 [2,082 kB] 
獲取:9 http://us.archive.ubuntu.com/ubuntu/ trusty/main libhtml-template-perl all 2.95-1 [65.5 kB] 
獲取:10 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server all 5.5.38-0ubuntu0.14.04.1 [12.4 kB] 
下載 8,343 kB,耗時 49秒 (168 kB/s) 
正在預設定軟件包 ... 
Selecting previously unselected package mysql-common. 
(正在讀取數據庫 ... 系統當前共安裝有 212184 個文件和目錄。) 
Preparing to unpack .../mysql-common_5.5.38-0ubuntu0.14.04.1_all.deb ... 
Unpacking mysql-common (5.5.38-0ubuntu0.14.04.1) ... 
Selecting previously unselected package libmysqlclient18:i386. 
Preparing to unpack .../libmysqlclient18_5.5.38-0ubuntu0.14.04.1_i386.deb ... 
Unpacking libmysqlclient18:i386 (5.5.38-0ubuntu0.14.04.1) ... 
Selecting previously unselected package libdbi-perl. 
Preparing to unpack .../libdbi-perl_1.630-1_i386.deb ... 
Unpacking libdbi-perl (1.630-1) ... 
Selecting previously unselected package libdbd-mysql-perl. 
Preparing to unpack .../libdbd-mysql-perl_4.025-1_i386.deb ... 
Unpacking libdbd-mysql-perl (4.025-1) ... 
Selecting previously unselected package libterm-readkey-perl. 
Preparing to unpack .../libterm-readkey-perl_2.31-1_i386.deb ... 
Unpacking libterm-readkey-perl (2.31-1) ... 
Selecting previously unselected package mysql-client-5.5. 
Preparing to unpack .../mysql-client-5.5_5.5.38-0ubuntu0.14.04.1_i386.deb ... 
Unpacking mysql-client-5.5 (5.5.38-0ubuntu0.14.04.1) ... 
Selecting previously unselected package mysql-server-core-5.5. 
Preparing to unpack .../mysql-server-core-5.5_5.5.38-0ubuntu0.14.04.1_i386.deb ... 
Unpacking mysql-server-core-5.5 (5.5.38-0ubuntu0.14.04.1) ... 
Processing triggers for man-db (2.6.7.1-1) ... 
正在設置 mysql-common (5.5.38-0ubuntu0.14.04.1) ... 
Selecting previously unselected package mysql-server-5.5. 
(正在讀取數據庫 ... 系統當前共安裝有 212532 個文件和目錄。) 
Preparing to unpack .../mysql-server-5.5_5.5.38-0ubuntu0.14.04.1_i386.deb ... 
Unpacking mysql-server-5.5 (5.5.38-0ubuntu0.14.04.1) ... 
Selecting previously unselected package libhtml-template-perl. 
Preparing to unpack .../libhtml-template-perl_2.95-1_all.deb ... 
Unpacking libhtml-template-perl (2.95-1) ... 
Selecting previously unselected package mysql-server. 
Preparing to unpack .../mysql-server_5.5.38-0ubuntu0.14.04.1_all.deb ... 
Unpacking mysql-server (5.5.38-0ubuntu0.14.04.1) ... 
Processing triggers for ureadahead (0.100.0-16) ... 
ureadahead will be reprofiled on next reboot 
Processing triggers for man-db (2.6.7.1-1) ... 
正在設置 libmysqlclient18:i386 (5.5.38-0ubuntu0.14.04.1) ... 
正在設置 libdbi-perl (1.630-1) ... 
正在設置 libdbd-mysql-perl (4.025-1) ... 
正在設置 libterm-readkey-perl (2.31-1) ... 
正在設置 mysql-client-5.5 (5.5.38-0ubuntu0.14.04.1) ... 
正在設置 mysql-server-core-5.5 (5.5.38-0ubuntu0.14.04.1) ... 
正在設置 mysql-server-5.5 (5.5.38-0ubuntu0.14.04.1) ... 
141010 16:29:54 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead. 
mysql start/running, process 31215 
正在設置 libhtml-template-perl (2.95-1) ... 
Processing triggers for ureadahead (0.100.0-16) ... 
正在設置 mysql-server (5.5.38-0ubuntu0.14.04.1) ... 
Processing triggers for libc-bin (2.19-0ubuntu6.1) ... 
MySQL Server安裝過程

 

mysql安裝完成後,咱們能夠經過netstat -tap|grep mysql來查看系統是否已經有了mysql服務。數據庫

出現上面的信息,說明咱們安裝mysql成功。ubuntu

 

執行如下命令能夠查看MySQL的版本:less

hadoop@master:~$ mysql -V 
mysql Ver 14.14 Distrib 5.5.38, for debian-linux-gnu (i686) using readline 6.3

 

下面進行簡單的配置ide

安裝完成後經過修改/etc/mysql/my.cnf(此文件爲mysql的配置文件)。將文件中的binding-address=127.0.0.1註釋掉。其它配置根據須要更改。oop

hadoop@master:~$ sudo vi /etc/mysql/my.cnf
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1

 

登陸數據庫:spa

hadoop@master:~$ msyql -u root -p 
未找到 'msyql' 命令,您要輸入的是不是: 
命令 'mysql' 來自於包 'percona-xtradb-cluster-client-5.5' (universe) 
命令 'mysql' 來自於包 'mysql-client-core-5.5' (main) 
命令 'mysql' 來自於包 'mariadb-client-core-5.5' (universe) 
命令 'mysql' 來自於包 'mysql-client-core-5.6' (universe) 
msyql:未找到命令

 

出現改錯誤緣由是沒有安裝MySQL客戶端,執行命令安裝MySQL對應的客戶端:

hadoop@master:~$ sudo apt-get install mysql-client 
正在讀取軟件包列表... 完成 
正在分析軟件包的依賴關係樹 
正在讀取狀態信息... 完成 
下列【新】軟件包將被安裝: 
mysql-client 
升級了 0 個軟件包,新安裝了 1 個軟件包,要卸載 0 個軟件包,有 158 個軟件包未被升級。 
須要下載 12.3 kB 的軟件包。 
解壓縮後會消耗掉 129 kB 的額外空間。 
獲取:1 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-client all 5.5.38-0ubuntu0.14.04.1 [12.3 kB] 
下載 12.3 kB,耗時 1秒 (10.2 kB/s) 
Selecting previously unselected package mysql-client. 
(正在讀取數據庫 ... 系統當前共安裝有 212633 個文件和目錄。) 
Preparing to unpack .../mysql-client_5.5.38-0ubuntu0.14.04.1_all.deb ... 
Unpacking mysql-client (5.5.38-0ubuntu0.14.04.1) ... 
正在設置 mysql-client (5.5.38-0ubuntu0.14.04.1) ...
hadoop@master:~$ sudo apt-get install mysql-client

 

安裝完成,再次登陸MySQL:

hadoop@master:~$ mysql -u root -p 
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 43 
Server version: 5.5.38-0ubuntu0.14.04.1 (Ubuntu) 

Copyright (c) 2000, 2014, 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遠程訪問:

mysql> grant all privileges on *.* to root@'%' identified by "root";
Query OK, 0 rows affected (0.01 sec)

 

重啓msyql服務便可遠程訪問

hadoop@master:~$ sudo service mysql restart 
mysql stop/waiting 
mysql start/running, process 32359

 

到此安裝和配置完成。

 

 


本文出自 「Forever Love」 博客,轉載請務必保留此出處http://www.cnblogs.com/dwf07223/p/4019944.html

相關文章
相關標籤/搜索