Linux 配置记录

Ubuntu 更换国内源

在国内使用国内源速度更快

修改文件 /etc/apt/sources.list 为以下源内容

清华源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

# 源码镜像
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

# 预发布软件源
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

阿里源

1
2
3
4
5
6
7
8
9
10
11
12
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

# 源码镜像
# deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiver

更新

1
2
apt update
apt upgrade

缺省 Ubuntu

安装 build-essential

1
apt install build-essential

配置 MySql

安装

1
apt install mysql-server

查看随机密码

1
cat /etc/mysql/debian.cnf

启动/停止

1
2
3
service mysql start
service mysql stop
service mysql restart

用户操作

删除

1
drop 'name'@'host';

创建

1
CREATE USER 'name'@'host' IDENTIFIED BY 'password';

刷新权限

1
FLUSH PRIVILEGES;

开启远程登陆

MySql 默认不允许远程登录,所以需要开启远程访问权限

只需将 host 字段设置为 % 即可

1
2
3
use mysql;
update user set host = '%' where user = 'name';
FLUSH PRIVILEGES;

查看用户

1
2
use mysql;
select user,host,plugin,authentication_string from user;

更改旧版验证方式

1
alter user 'name'@'%' identified with mysql_native_password by 'password';

大小写敏感

需要做以下操作

删除现有数据

必须删除现有数据才有效

1
2
3
service mysql stop
rm -rf /var/lib/mysql/
mkdir /var/lib/mysql/

修改配置

1
2
3
4
# Ubuntu下配置文件是/etc/mysql/mysql.conf.d/mysqld.cnf
# CentOS下配置文件是/etc/my.cnf,在[mysqld]下添加配置

lower_case_table_names = 0/1/2

初始化

1
2
mysqld --initialize
service mysql start

卸载

1
2
3
4
rm -rf /var/lib/mysql/
rm -rf /etc/mysql/
apt autoremove mysql* --purge
apt remove apparmor

安装 docker

  1. 阿里云
1
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
  1. daocloud
1
curl -sSL https://get.daocloud.io/docker | sh