使用 mysqldump 备份和数恢复数据库
一、备份数据库 mysql 自带了数据库备份工具 mysqldump 可以很方便的对数据库进行备份:
|
1 |
mysqldump -u root -p --all-database > db.sql |
以上命令就完成了一次数据备份,备份后的数据保存在文件 db.sql,参数--all-databases 是指备份所有数据库。 如果只想备份特定 ... 阅读更多
一、备份数据库 mysql 自带了数据库备份工具 mysqldump 可以很方便的对数据库进行备份:
|
1 |
mysqldump -u root -p --all-database > db.sql |
以上命令就完成了一次数据备份,备份后的数据保存在文件 db.sql,参数--all-databases 是指备份所有数据库。 如果只想备份特定 ... 阅读更多
一、镜像和容器 docker 中的镜像和容器对应 linux 环境中的程序和进程,不运行时是一个静态的二进制文件,运行就成了系统中的一个进程。 docker 运行时被称作容器,静态的文件则被称作镜像。 镜像是 docker 三大核心中最为重要的,因为运行 docker 首先得要有镜像。而镜像的来源有多种,可以从官方仓 ... 阅读更多
昨天给 shell 的 prompt 设置了终端颜色,今天突然奇想能不能给 mysql 的 prompt 也设置颜色,网上查了一下还真有,在.bashrc 中添加以下设置即可开启颜色:
|
1 |
alias mysql=$(echo -e 'mysql --prompt="\x1B[01;32m(\N)\x1B[0m \x1B[34m[\d]\x1B[0m> "') |
显示效果如下: 上面的代码中,\x1B 表示颜色设置开始,紧接着 [0 ... 阅读更多
不知道从哪天起,使用 xshell 的终端主机名和用户名没有了颜色: ls 变色了,而命令行开始的 ma@Y485 这一段是白色,和其他部分一样颜色不太显眼。 解决方法: 在~/.bashrc 中其实有了颜色的设置,查看代码可以发现:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
ma@Y485:~$ sed -n '38,65p' .bashrc # set a fancy prompt (non-color, unless we know we "want" color) case "$TERM" in xterm-color|*-256color) color_prompt=yes;; esac # uncomment for a colored prompt, if the terminal has the capability; turned # off by default to not distract the user: the focus in a terminal window # should be on the output of commands, not on the prompt # force_color_prompt=yes if [ -n "$force_color_prompt" ]; then if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then # We have color support; assume it's compliant with Ecma-48 # (ISO/IEC-6429). (Lack of such support is extremely rare, and such # a case would tend to support setf rather than setaf.) color_prompt=yes else color_prompt= fi fi if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi unset color_prompt force_color_prompt |
最下面有一 ... 阅读更多
一、 IPv6 表示法 IPv6 于上世纪 90 年代提出,当时提出的目的是为了扩展极度匮乏的 IPv4 地址。 然而到现在二十多年的发展历程中,虽然一直都在强调要推广它的使用,但至今依旧是不温不火的状态。 IPv6 地址有 128 位,是 IPv4 长度的 4 倍,IPv4 一般使用点来隔开每一个字节,如 192.168.10. ... 阅读更多
一、基本用法 ifconfig 网卡操作命令,可以用来启动、设置和修改网络配置。 直接使用命令可以查看当前主机所有网卡的信息:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[ma@localhost ~]$ ifconfig eth0 Link encap:Ethernet HWaddr 20:89:84:49:EF:46 inet addr:192.168.123.58 Bcast:192.168.123.255 Mask:255.255.255.0 inet6 addr: abcd::ff03/120 Scope:Global UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:919 errors:0 dropped:0 overruns:0 frame:0 TX packets:419 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:78144 (76.3 KiB) TX bytes:47656 (46.5 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) |
其中,eth0 是本地网卡信息,lo 是本地环回地址,也可以直接在命令后面加网卡名来查看指定网卡的信息: [cr ... 阅读更多