mysql8.0安装备份

一、安装

操作系统ubuntu22

先确认是否安装过mysql。

1
$ dpkg -l | grep mysql #检测是否安装mysql

安装mysql

1
2
$ sudo apt-get install mysql-server
$ mysql --version #查看版本

mysql -uroot -p 进不去

默认密码不知道,MySql 从8.0开始修改密码有了变化,在user表加了字段authentication_string,修改密码前先检查authentication_string是否为空,先暂停mysql,用mysqld_safe启动,给authentication_string赋值,再修改密码

1
2
3
4
5
6
7
8
$ sudo /etc/init.d/mysql stop
$ sudo mkdir /var/run/mysqld
$ sudo chown mysql /var/run/mysqld
$ sudo mysqld_safe --skip-grant-tables&
$ mysql -uroot -p
mysql> UPDATE mysql.user SET authentication_string=null WHERE User='root';
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
mysql> flush privileges;

重启服务

1
2
$ sudo killall -u mysql
$ sudo /etc/init.d/mysql start

二、在数据库插入数据

查看数据库

1
2
3
mysql> SHOW DATABASES;
mysql> CREATE DATABASE test_db;
mysql> use test_db;

创建表

1
2
3
4
5
6
7
create table tb_tmp01
(
id INT(11),
name VARCHAR(25)
);

show tables;

插入数据

1
2
insert tb_tmp01(id,name) value('01','小明');
select * from tb_tmp01;

三、备份

1
2
$ mysqldump -uroot -p123456 --all-databases >/home/fanyun/下载/all.sql
$ mysqldump -uroot -p123456 --databases test_db >/home/fanyun/下载/test_db.sql

四、恢复

1
$ mysql -uroot -p123456 test_db < test_db.sql

采用备份磁盘文件

1
2
$ tar -cvf sql.tar /usr/local/mysql/data #压缩
$ tar -xvf sql.tar #解包

linux 常用命令

cp复制 rm删除 mv移动 mkdir创建文件夹 history查看历史命令记录

ps 查看进程

1
ps -ef | grep 进程关键字

chmod 权限管理

1
2
3
chmod 777 file
chmod +x file
chmod u+x file
who 用户类型 说明
u user 文件所有者
g group 文件所有者所在组
o others 所有其他用户
a all 所有用户, 相当于 ugo

笔记:各种国内源

ubuntu服务器换软件源

1
2
3
4
5
6
# 备份原始源文件sources.list
$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
# 编辑文件
$ vi /etc/apt/sources.list
# 保存文件后更新一下
$ sudo apt update

ubuntu桌面换软件源

中国科学技术大学开源软件镜像

笔记:首次使用HEXO

安装node

windows系统官网下载
node16.20.0

因为在此系统上禁止运行脚本

set-ExecutionPolicy RemoteSigned

安装node版本管理器nvm,安装node16.20.0

1
2
3
$ npm install -g n  
$ nvm install 16.20.0
$ nvm use 16.20.0

官方原生搭建

1
2
3
4
5
$ npm install hexo-cli -g
$ hexo init blog
$ cd blog
$ npm install
$ hexo server

查看hexo版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$ hexo -v
INFO Validating config
hexo: 6.3.0
hexo-cli: 4.3.0
os: win32 10.0.22621
node: 16.20.0
v8: 9.4.146.26-node.26
uv: 1.43.0
zlib: 1.2.11
brotli: 1.0.9
ares: 1.19.0
modules: 93
nghttp2: 1.47.0
napi: 8
llhttp: 6.0.10
openssl: 1.1.1t+quic
cldr: 41.0
icu: 71.1
tz: 2022f
unicode: 14.0
ngtcp2: 0.8.1
nghttp3: 0.7.0

npm更新包工具

1
2
$ npm install npm-check-updates -g
$ ncu -u

配置_config.yml

再续

插件

生成永久链接

1
npm install hexo-abbrlink --save

配置_config.yml

1
2
3
4
permalink: blog/:abbrlink.html # 也可以直接写 :abbrlink/
abbrlink:
alg: crc32 #算法: crc16(default) and crc32
rep: dec #进制: dec(default) and hex

题外话

vuepress 太难用了,官方教程乱七八糟,没有个统一规则。2.0主题数量又太少,搭建都能报错,配置一天失败告终。
总结:自己水平不行。

管理github

1
2
3
4
5
git init
git remote add origin https://github.com/fateplayer/hexoblog
git branch -a
git fetch
git checkout origin/main

Hello World

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment