后台开发学习笔记(十八、mysql安装)

对于我这种非专业的人来说,mysql还是第一次搞,也没关系,又了第一次之后,以后就简单了,这里写写学习mysql的过程。

18.1 mysql的安装

第一步,是安装,我们使用一个软件必须要安装才行把,我大体在网上浏览了一波,有3中安装方式:

  1. 用rpm直接用命令行安装
  2. 下载了软件包,用命令行安装
  3. 下载源码包,然后开始瞎搞

这里我选用第二种,为什么第二种呢,因为第一种用rmp的命令安装,太没成就感了,一个命令搞定,总感觉缺少了一点探索精神,但是第3种就有点找罪受的感觉了,没事找事用源码包安装干嘛,除非是要专门研究mysql的,可以尝试一下用源码安装,不过用第2种,折中的方法安装,应该是比较合适的。

18.1.1 mysql的下载

说实话,我个人比较喜欢在官网上下载,不过因为都是外国的网站,如果网速比较差的话,直接下载会很慢的,为什么喜欢在官网下载了,因为官网是比较全面的,下次在找更新的版本也能找到,有一些官网是有一些历程的,如果可以的话,可以看一下官网的信息。

mysql下载地址
在这里插入图片描述
我目前用的debian系统,所以找了debian的一个安装包,如果以后用了centos系统,发现跟debian的安装步骤不一样的话,再重新写一篇文档记录。

在这里插入图片描述
我比较喜欢这种大而全的东西,所以我下载了一个最大的包,解压开的图片:
在这里插入图片描述
确实大而全,然后找到mysql-community-server_8.0.19-1debian9_i386.deb这个安装包,然后把他丢到Debian系统中,开始安装,然后安装的时候报错了

root@debian:~/mysql# dpkg -i mysql-community-server_8.0.19-1debian9_i386.deb 
Selecting previously unselected package mysql-community-server.
(Reading database ... 48229 files and directories currently installed.)
Preparing to unpack mysql-community-server_8.0.19-1debian9_i386.deb ...
Unpacking mysql-community-server (8.0.19-1debian9) ...
dpkg: dependency problems prevent configuration of mysql-community-server:
 mysql-community-server depends on mysql-common (>= 8.0.19-1debian9); however:
  Package mysql-common is not installed.
 mysql-community-server depends on mysql-client (= 8.0.19-1debian9); however:
  Package mysql-client is not installed.
 mysql-community-server depends on mysql-community-server-core (= 8.0.19-1debian9); however:
  Package mysql-community-server-core is not installed.
 mysql-community-server depends on psmisc; however:
  Package psmisc is not installed.

dpkg: error processing package mysql-community-server (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-community-server
root@debian:~/mysql# 

就是提示一些依赖包没有安装好,下面把依赖包都安装一下。

root@debian:~/mysql# dpkg -i mysql-common_8.0.19-1debian9_i386.deb 
Selecting previously unselected package mysql-common.
(Reading database ... 48249 files and directories currently installed.)
Preparing to unpack mysql-common_8.0.19-1debian9_i386.deb ...
Unpacking mysql-common (8.0.19-1debian9) ...
Setting up mysql-common (8.0.19-1debian9) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode

mysql的共同包安装成功,接下来继续:

root@debian:~/mysql# dpkg -i mysql-community-client-core_8.0.19-1debian9_i386.deb 
Selecting previously unselected package mysql-community-client-core.
(Reading database ... 48316 files and directories currently installed.)
Preparing to unpack mysql-community-client-core_8.0.19-1debian9_i386.deb ...
Unpacking mysql-community-client-core (8.0.19-1debian9) ...
Setting up mysql-community-client-core (8.0.19-1debian9) ...
Processing triggers for man-db (2.7.6.1-2) ...

root@debian:~/mysql# dpkg -i mysql-community-client_8.0.19-1debian9_i386.deb 
(Reading database ... 48328 files and directories currently installed.)
Preparing to unpack mysql-community-client_8.0.19-1debian9_i386.deb ...
Unpacking mysql-community-client (8.0.19-1debian9) over (8.0.19-1debian9) ...
Setting up mysql-community-client (8.0.19-1debian9) ...
Processing triggers for man-db (2.7.6.1-2) ...

root@debian:~/mysql# dpkg -i mysql-client_8.0.19-1debian9_i386.deb 
(Reading database ... 48328 files and directories currently installed.)
Preparing to unpack mysql-client_8.0.19-1debian9_i386.deb ...
Unpacking mysql-client (8.0.19-1debian9) over (8.0.19-1debian9) ...
Setting up mysql-client (8.0.19-1debian9) ...

这是把客户端部分也全部安装了,接下来安装server-core

dpkg -i mysql-community-server-core_8.0.19-1debian9_i386.deb 
Selecting previously unselected package mysql-community-server-core.
(Reading database ... 48328 files and directories currently installed.)
Preparing to unpack mysql-community-server-core_8.0.19-1debian9_i386.deb ...
Unpacking mysql-community-server-core (8.0.19-1debian9) ...

dpkg: dependency problems prevent configuration of mysql-community-server-core:
 mysql-community-server-core depends on libaio1 (>= 0.3.93); however:
  Package libaio1 is not installed.
 mysql-community-server-core depends on libmecab2; however:
  Package libmecab2 is not installed.
 mysql-community-server-core depends on libnuma1 (>= 2.0.11); however:
  Package libnuma1 is not installed.

dpkg: error processing package mysql-community-server-core (--install):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Errors were encountered while processing:
 mysql-community-server-core

想不到server-core还要依赖别的东西,没办法了,继续安装

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 mysql-community-server : Depends: psmisc but it is not installed
 mysql-community-server-core : Depends: libaio1 (>= 0.3.93) but it is not installed
                               Depends: libmecab2 but it is not installed
                               Depends: libnuma1 (>= 2.0.11) but it is not installed
                               Recommends: mecab-ipadic-utf8 but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

尝试的安装,然后怎么都装不了,更新啥的,然后看了这个提示信息,别人是有提示的,感觉立马抓住了新大陆,然后就用了一下提示的命令试试:

root@debian:~/mysql# apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libc-l10n libevent-2.0-5 libjim0.76 libssh2-1 tcpd
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  libaio1 libmecab2 libnuma1 psmisc
The following NEW packages will be installed:
  libaio1 libmecab2 libnuma1 psmisc
0 upgraded, 4 newly installed, 0 to remove and 273 not upgraded.
2 not fully installed or removed.
Need to get 352 kB of archives.
After this operation, 2,306 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
WARNING: The following packages cannot be authenticated!
  libaio1 libmecab2 libnuma1 psmisc
Install these packages without verification? [y/N] y
Get:1 http://mirrors.aliyun.com/ubuntu bionic-updates/main i386 libaio1 i386 0.3.110-5ubuntu0.1 [6,816 B]
Get:2 http://mirrors.aliyun.com/ubuntu bionic/universe i386 libmecab2 i386 0.996-5 [269 kB]
Get:3 http://mirrors.aliyun.com/ubuntu bionic-updates/main i386 libnuma1 i386 2.0.11-2.1ubuntu0.1 [23.6 kB]                                                                                                                                                                          
Get:4 http://mirrors.aliyun.com/ubuntu bionic-updates/main i386 psmisc i386 23.1-1ubuntu0.1 [53.3 kB]   

结果一试,吓一跳,真的安装成功了,真想不到啊,然后安装的过程中,又提示输入密码,啥的,就正常输入就可以了。然后接着安装以前没有安装的sever-core.

root@debian:~/mysql# dpkg -i mysql-community-server-core_8.0.19-1debian9_i386.deb 
(Reading database ... 48495 files and directories currently installed.)
Preparing to unpack mysql-community-server-core_8.0.19-1debian9_i386.deb ...
Unpacking mysql-community-server-core (8.0.19-1debian9) over (8.0.19-1debian9) ...
Setting up mysql-community-server-core (8.0.19-1debian9) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.7.6.1-2) ...
root@debian:~/mysql# 

这个果然安装成功了,到现在这里我们的依赖包已经安装的查不到,接下来就安装我们第一次要安装的程序了,

root@debian:~/mysql# dpkg -i mysql-community-server_8.0.19-1debian9_i386.deb 
(Reading database ... 48495 files and directories currently installed.)
Preparing to unpack mysql-community-server_8.0.19-1debian9_i386.deb ...
Unpacking mysql-community-server (8.0.19-1debian9) over (8.0.19-1debian9) ...
Setting up mysql-community-server (8.0.19-1debian9) ...

这次就表示中安装成,想不到这么顺利就安装成功了,不过还要查看一下是否真的成功了,总感觉成功来的太容易了,

18.2 测试是否安装成功

像我们刚刚是默认安装的,其实有指定目录安装,不过像linux都是直接安装,那些安装的路径在哪里呢,其实我也不知道,不过我们又终极必杀技,全盘搜索

root@debian:/# find . -name "mysql*"

终于在全盘搜索的努力下,终于找到了mysql安装的路径,在
在这里插入图片描述
然后我们进入/usr/bin目录中,查找mysql的程序,还真有,那一步就是执行了,这个程序的执行是需要带参数的,

root@debian:/usr/bin# ./mysql -h localhost -u root -p

参数的意思,不知道可以通过–help命令来查看,如果在linux下操作,并且会英语,那肯定是一个无敌的存在,因为一些帮组信息都是英文。

我这里大概说一下参数的意思:
-h, --host=name Connect to host. 连接这个mysql的主机名字
-u, --user=name User for login if not current user. 登录mysql的用户名
-p, --password[=name]
Password to use when connecting to server. If password is
not given it’s asked from the tty. 是登录的密码

然后我们按回车,这时候就会提示输入密码,然后我们输入密码,然后欢迎来到mysql的世界。

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.19 MySQL Community Server - GPL

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> status
--------------
./mysql  Ver 8.0.19 for Linux on x86_64 (MySQL Community Server - GPL)

Connection id:		9
Current database:	
Current user:		root@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server version:		8.0.19 MySQL Community Server - GPL
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	utf8mb4
Db     characterset:	utf8mb4
Client characterset:	utf8mb4
Conn.  characterset:	utf8mb4
UNIX socket:		/var/run/mysqld/mysqld.sock
Binary data as:		Hexadecimal
Uptime:			6 min 42 sec

Threads: 2  Questions: 6  Slow queries: 0  Opens: 115  Flush tables: 3  Open tables: 35  Queries per second avg: 0.014
--------------

mysql> 

这里记录一下,如果要想退出这个mysql的模式,用输入exit才能退出,q不做提出处理。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值