现在的软件越来越好安装,尤其是在ubuntu下安装软件,更是没有技巧,只需要在联网的情况下使用apt-get inatll 即可。在决定安装mysql之前,要先确定系统是否已经安装mysql。
hadoop@master:~$ netstat -tap | grepmysql
(并非所有进程都能被检测到,所有非本用户的进程信息将不会显示,如果想看到所有信息,则必须切换到 root 用户)
由此可以看出系统中并没有安装mysql,执行以下命令进行安装。
hadoop@master:~$ sudo apt-get install mysql-server
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
将会安装下列额外的软件包:
libdbd-mysql-perl libdbi-perl libhtml-template-perllibmysqlclient18
libterm-readkey-perl mysql-client-5.5 mysql-common mysql-server-5.5mysql-server-core-5.5建议安装的软件包:
libmldbm-perl libnet-daemon-perl libplrpc-perl libsql-statement-perllibipc-sharedcache-perltinyca mailx
下列【新】软件包将被安装:
libdbd-mysql-perl libdbi-perl libhtml-template-perllibmysqlclient18
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,343kB 的软件包。
解压缩后会消耗掉86.8MB 的额外空间。
您希望继续执行吗? [Y/n]
sudo apt-get install mysql-server
输入Y进入到安装界面,在安装过程中,会弹出一个界面要求输入mysql的root的密码,这里一定输入,省得安装后再设密码了。
再次输入密码:
获取: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 triggersfor 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 triggersfor ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
Processing triggersfor 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 ina future release. Please use the full name instead.
mysql start/running, process 31215正在设置 libhtml-template-perl (2.95-1) ...
Processing triggersfor ureadahead (0.100.0-16) ...
正在设置 mysql-server (5.5.38-0ubuntu0.14.04.1) ...
Processing triggersfor libc-bin (2.19-0ubuntu6.1) ...
MySQL Server安装过程
mysql安装完成后,我们可以通过netstat -tap|grep mysql来查看系统是否已经有了mysql服务。
出现上面的信息,说明我们安装mysql成功。
执行以下命令可以查看MySQL的版本:
hadoop@master:~$ mysql -V
mysql Ver14.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注释掉。其它配置根据需要更改。
hadoop@master:~$ sudo vi /etc/mysql/my.cnf
# Instead of skip-networking the default is now to listen only on
# localhostwhich is more compatible and is not lesssecure.
#bind-address = 127.0.0.1
登录数据库:
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.3kB 的软件包。
解压缩后会消耗掉129kB 的额外空间。
获取: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 connectionid is 43Server 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 clearthe 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:~$ sudoservice mysql restart
mysql stop/waiting
mysql start/running, process 32359
到此安装和配置完成。