关系型数据库
MySQL是一种关系型数据库管理系统,采用了关系模型来组织数据的数据库,关系数据库将数据保存在不同的表中,用户通过查询 sql 来检索数据库中的数据。
yum 方式安装 mysql
bash
# yum -y install mysql-server
# systemctl start mysqld
获取初始密码并登录 mysql
bash
# grep 'temporary password' /var/log/mysqld.log
2024-05-08T18:18:35.856539Z 1 [Note] A temporary password is generated for root@localhost: ige6?TWHte9H
# mysql -u root -p
修改 mysql用户 密码,5.7.9 之后和之前的修改密码方式有区别
修改root用户的登录密码并修改密码规则设置简单的密码,注意修改密码后执行 flush 命令刷新一下权限:
bash
> ALTER USER 'root'@'localhost' IDENTIFIED BY 'ige6?TWHte9H';
> SHOW VARIABLES LIKE 'validate_password%';
> SET GLOBAL validate_password_policy=0;
> SET GLOBAL validate_password_length=4;
> ALTER USER 'root'@'localhost' IDENTIFIED BY '1234';
> flush privileges;
> exit
在 mysql 中查询一些基础信息
查看是否开放服务端口(3306)
bash
> show variables like '%port%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| innodb_support_xa | ON |
| large_files_support | ON |
| port | 3306 |
| report_host | |
| report_password | |
| report_port | 3306 |
| report_user | |
| require_secure_transport | OFF |
+--------------------------+-------+
8 rows in set (0.00 sec)
设置 root 用户为可远程访问
bash
> select user,host from user;
+---------------+-----------+
| user | host |
+---------------+-----------+
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+-----------+
> update user set host='%' where user='root';