Ubuntu 14.04下MySQL服务器和客户端的安装

下面进行简单的配置

安装完成后通过修改/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
# localhost which is more compatible and is not less secure.
#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:未找到命令
按 Ctrl+C

出现改错误原因是没有安装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) ...

安装完成,再次登录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

到此安装和配置完成。

posted @ 2019-01-08 17:20  小强找BUG  阅读(159)  评论(0编辑  收藏  举报