標籤:ubuntu mysql
現在的軟體越來越好安裝,尤其是在ubuntu下安裝軟體,更是沒有技巧,只需要在連網的情況下使用apt-get inatll 即可。在決定安裝mysql之前,要先確定系統是否已經安裝mysql。
[email protected]:~$ netstat -tap | grep mysql (並非所有進程都能被檢測到,所有非本使用者的進程資訊將不會顯示,如果想看到所有資訊,則必須切換到 root 使用者)
由此可以看出系統中並沒有安裝mysql,執行以下命令進行安裝。
[email protected]:~$ 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的密碼,這裡一定輸入,省得安裝後再設密碼了。
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/4C/38/wKiom1Q5TwrD_HDeAAGN_of_IJE149.jpg" title="1.png" alt="wKiom1Q5TwrD_HDeAAGN_of_IJE149.jpg" />
再次輸入密碼:
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/4C/3A/wKioL1Q5T43xLjglAADHLRvfo8Q629.jpg" title="2.png" alt="wKioL1Q5T43xLjglAADHLRvfo8Q629.jpg" />
擷取: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) ... 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服務。
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/4C/38/wKiom1Q5T5agERVqAACr7cjhJCg443.jpg" title="3.png" alt="wKiom1Q5T5agERVqAACr7cjhJCg443.jpg" />
出現上面的資訊,說明我們安裝mysql成功。
執行以下命令可以查看MySQL的版本:
[email protected]:~$ mysql -V mysql Ver 14.14 Distrib 5.5.38, for debian-linux-gnu (i686) using readline 6.3
下面進行簡單的配置
安裝完成後通過修改/etc/mysql/my.cnf(此檔案為mysql的設定檔)。將檔案中的binding-address=127.0.0.1注釋掉。其它配置根據需要更改。
[email protected]:~$ 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
登入資料庫:
[email protected]:~$ 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對應的用戶端:
[email protected]:~$ 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) ...[email protected]:~$ sudo apt-get install mysql-client
安裝完成,再次登入MySQL:
[email protected]:~$ 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 [email protected]‘%‘ identified by "root";Query OK, 0 rows affected (0.01 sec)
重啟msyql服務即可遠端存取
[email protected]:~$ sudo service mysql restart mysql stop/waiting mysql start/running, process 32359
到此安裝和配置完成。
本文出自 “Forever Love” 部落格,請務必保留此出處http://dwf07223.blog.51cto.com/8712758/1562758
Ubuntu 14.04下MySQL伺服器和用戶端的安裝