这是我参与8月更文挑战的第4天,活动详情查看:8月更文挑战
一. 前言
mysql的安装相对来说比较简单,在centos6的系统里使用yum安装是最省事的做法,不过为了让大家熟悉mysql官网,在这里我们演示rpm包的安装方式 本机使用的操作系统为: centos6.9
二. rpm 包下载
数据包下载: www.mysql.com/downloads/
linuxnux平台上推荐使用RPM包来安装Mysql,MySQL 提供了以下RPM包的下载地址:
- MySQL-MySQL服务器。你需要该选项,除非你只想连接运行在另一台机器上的MySQL服务器。
- MySQL-client - MySQL 客户端程序,用于连接并操作Mysql服务器。
- MySQL-devel - 库和包含文件,如果你想要编译其它MySQL客户端,例如Perl模块,则需要安装该RPM包。
- MySQL-shared - 该软件包包含某些语言和应用程序需要动态装载的共享库(libmysqlclient.so*),使用MySQL。
- MySQL-bench - MySQL数据库服务器的基准和性能测试工具。
下载截图:
1) 选择 mysql community server
2) 我们选择其他GA版本
3) 选择5.6的版本下载
三. 上传到服务器
四. 安装mysql
[root@gaosh-1 ~]# yum remove mysql -y
[root@gaosh-1 ~]# rpm -ivh MySQL-server-5.6.49-1.el6.x86_64.rpm
五. 启动mysql并检查是否启动
[root@gaosh-1 ~]# /etc/init.d/mysql start
Starting MySQL.Logging to '/var/lib/mysql/gaosh-1.err'.
.. SUCCESS!
启动完成后,我们可以通过以下命令查看端口号3306是否开启
[root@gaosh-1 ~]# ss -lntp |grep mysql
LISTEN 0 80 :::3306 :::* users:(("mysqld",45526,10))
[root@gaosh-1 ~]#
看到 LISTEN 和后面的端口号3306,则证明数据库已经开启
六. 查看登陆密码并登陆
我之前在前面的文章中有提到过密码登陆的方法,这次我们使用shell脚本命令的形式来查看: [root@gaosh-1 ~]# cat /root/.mysql_secret |awk -F: '{print $4}' ShF5U8sDZM68hteE
安装客户端 [root@gaosh-1 ~]# yum localinstall MySQL-client-5.6.49-1.el6.i686.rpm
登陆测试:
[root@gaosh-1 ~]# mysql -uroot -pShF5U8sDZM68hteE
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.49
Copyright (c) 2000, 2020, 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>
如上所示,表示已经安装成功,且你那个正常登陆。
七. 日志及配置文件目录
[root@gaosh-1 mysql]# find / -name mysql
/etc/logrotate.d/mysql
/etc/rc.d/init.d/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/var/lock/subsys/mysql
/usr/share/mysql
/usr/lib64/mysql
/usr/bin/mysql
总结:
我们已经利用几篇文章来分别演示了,不同版本的系统,安装不同版本的MySQL数据库的方法,相信你已经对MySQL的实施部署有了自己的方法论
明天开始我们要进行增删改查的练习,请提前参考今天或者之前的文章安装好自己想要使用的MySQL版本。