第四天笔记

1.ls查看文件区域
ls常用命令显示:  - l  :长格式显示
                            - A:显示所有文件,包括隐藏文档(隐藏文件: .+文件)
                            - a :显示所有文件,包括.与..
                            - d :显示目录的属性
                            - h :提供易读的容量单位(K,M等)
[root@1 ~]# ls /etc/passwd -l         //系统用户配置文件
-rw-r--r--. 1 root root 983 Jul  8 12:40 /etc/passwd
[root@1 ~]# ls /etc/shadow -l        // 用于存储 Linux 系统中用户的密码信息,又称为“影子文件”
----------. 1 root root 621 Jul  8 12:40 /etc/shadow
[root@1 ~]# ls /etc/group -l          //用户组配置文件
-rw-r--r--. 1 root root 515 Jul  8 12:40 /etc/group
[root@1 ~]# ls /etc/gshadow -l    //加密资讯文件
----------. 1 root root 407 Jul  8 12:40 /etc/gshadow
[root@1 ~]# ls -al /etc/skel/        //新用户配置文件
total 24
drwxr-xr-x.  2 root root   62 Apr 11  2018 .
drwxr-xr-x. 77 root root 8192 Jul 11 08:44 ..
-rw-r--r--.  1 root root   18 Apr 11  2018 .bash_logout
-rw-r--r--.  1 root root  193 Apr 11  2018 .bash_profile
-rw-r--r--.  1 root root  231 Apr 11  2018 .bashrc
[root@1 ~]# ls -l /var/spool/mail/      //邮件存储目录
total 0
-rw-rw----. 1 zz mail 0 Jul  8 12:40 zz
[root@1 ~]# ls -al /home/           // root用户的家目录
total 0
drwxr-xr-x.  3 root root  16 Jul  8 12:40 .
dr-xr-xr-x. 17 root root 224 Jul  8 12:40 ..
drwx------.  2 zz   zz    62 Jul  8 12:40 zz
2.用户名密码占位 (x)
[root@1 ~]# vim /etc/passwd

3.window要修改为管理员,就修改组

    直接修改用户uid就可变成超级用户(不建议,超级用户一般为root)

    影子文件:/etc/shadow

md5进行加密(123位)之后,若密码一样,则加密串一样
sha512不会因为密码相同产生相同的加密串
更新密码的时间微软1900.1.1开始,其他1970.1.1开始
密码失效时间从更新后开始
每个用户只能有一个初始组,可以有多个附加组
创建一个用户并操作

/etc/skel是家目录的模板
在liunx系统中部署mysql
1. 安装MySQL前,需将系统自带的mariadb卸载
[root@k8s01 ~]#  rpm ‐qa|grep mariadb
mariadb‐libs‐5.5.52‐1.el7.x86_643
[root@k8s01 ~]#  rpm ‐e ‐‐nodeps mariadb‐libs‐5.5.52‐1.el7.x86_644
[root@k8s01 ~]#  rpm ‐qa|grep mariadb
2.下载安装包
3.具体安装步骤
    解压: [root@1 ~]#  [root@localhost ~]# tar -zxvf /opt/mysql-8.0.28-el7-x86_64.tar.gz -C /usr/local
     将MySQL根目录重命名为mysql: [root@1 ~]# mv /usr/local/mysql-8.0.28-el7-x86_64 /usr/local/mysql
    删除压缩文件: [root@1 ~]# rm -f mysql-8.0.28-el7-x86_64.tar.gz
    创建目录: [root@1 ~]# mkdir /usr/local/mysql/data
    更改环境变量: [root@1 ~]# vim /etc/profile
                 export PATH=/usr/local/mysql/bin:$PATH
    重载文件: [root@1 ~]# source /etc/profile
    查找mysql配置路径: [root@1 ~]# mysql --help | grep 'my.cnf'
                                      order of preference, my.cnf, $MYSQL_TCP_PORT,
                        /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
    配置mysql服务: [root@1 ~]# vim /etc/my.cnf
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置端口
port=3306
socket=/tmp/mysql.sock
#设置mysql根目录
basedir=/usr/local/mysql
#设置数据库的数据存放目录
datadir=/usr/local/mysql/data
#设置最大连接数
max_connections=200
#设置mysql服务端字符集,默认为latin1
character-set-server=UTF8MB4
#设置默认存储引擎
default-storage-engine=INNODB
#设置密码永不过期
default_password_lifetime=0
#设置 server接受的数据包大小
max_allowed_packet=16M
    
    添加组和用户; [root@1 ~]# groupadd mysql
                             [root@1 ~]# useradd -r -g mysql mysql
    变更用户和用户组: [root@1 ~]# chown -R mysql:mysql /usr/local/mysql
    初始化: [root@1 ~]# mysqld --initialize --user=mysql
2024-07-11T09:10:02.026598Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.28) initializing of server in progress as process 3186
2024-07-11T09:10:02.056727Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-07-11T09:10:02.935174Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-07-11T09:10:04.539330Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ;kVhWbXhI0tJ(临时密码)
开机启动
复制启动脚本到资源目录: [root@1 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
添加执行权限:[root@1 ~]# chmod +x /etc/rc.d/init.d/mysqld
添加至系统服务:[root@1 ~]# chkconfig --add mysqld
查询服务:[root@1 ~]# chkconfig --list mysqld    (适用于VMware17 ,16需要下载 libaio插件)

启服务:[root@1 ~]# service mysqld start

开放端口

添加端口:[root@1 ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent

重新加载:[root@1 ~]# firewall-cmd --reload

修改密码:[root@1 ~]# mysql -uroot -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.28
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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> alter user 'root'@'localhost' identified by '0000';   //重新更改的密码
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
允许远程连接:[root@1 ~]# mysql -uroot -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.28 MySQL Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.09 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit

  • 14
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值