【数据库】-1 mysql 的安装
文章目录
- 1、mysql数据库
- 1.1 mysql数据库的简要介绍
- 2、mysql数据库的安装
- 2.1 centos安装
- 2.2 ubuntu安装
1、mysql数据库
1.1 mysql数据库的简要介绍
MySQL是一种开源的关系型数据库管理系统(RDBMS),由瑞典MySQL AB公司开发,目前属于Oracle旗下产品。它基于客户机/服务器架构,支持多用户、多线程,能高效处理大量数据。MySQL使用标准SQL语言进行数据操作,具备存储过程、触发器、视图等高级功能,可满足不同场景的业务需求。其特点包括轻量快速、稳定性高、易于安装和维护,且提供了多种存储引擎(如InnoDB、MyISAM等),支持事务处理、外键约束等特性。由于开源免费(社区版)、跨平台兼容(Windows、Linux、Mac等),MySQL被广泛应用于Web开发、企业级应用、数据分析等领域,是LAMP(Linux + Apache + MySQL + PHP)等经典技术栈的核心组件之一,在全球范围内拥有庞大的用户群体和丰富的生态支持。
2、mysql数据库的安装
官方网站:
https://dev.mysql.com/downloads/
2.1 centos安装
官网界面
安装教程:
https://dev.mysql.com/doc/refman/8.4/en/linux-installation-yum-repo.html
systemctl start mysqld
systemctl status mysqld
centos安装的有一个初始密码
#登录成功
[root@localhost opt]# mysql -uroot -p'zg6gerhiuZ:h'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.4.5Copyright (c) 2000, 2025, 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>
mysql> alter user root@'localhost' identified by 'Admin@123';
Query OK, 0 rows affected (0.01 sec)#centos初次使用必须重置密码mysql> set global validate_password_policy=0;
ERROR 1193 (HY000): Unknown system variable 'validate_password_policy'
#mysql8.0及以上版本不再支持_policy 要使用.policy
mysql> SET GLOBAL validate_password.policy = LOW;
Query OK, 0 rows affected (0.00 sec)
mysql> SET GLOBAL validate_password.length = 4;
Query OK, 0 rows affected (0.00 sec)
#减少密码复杂性要求
mysql> ALTER USER root@'localhost' IDENTIFIED BY 'abc123';
Query OK, 0 rows affected (0.00 sec)
#设置新的密码
2.2 ubuntu安装
apt update
apt install -y mysql-server
即安装完成
apt安装的默认初始没有密码
ubuntu可以直接修改密码
mysql> alter user root@'localhost' identified by 'abc123';
Query OK, 0 rows affected (0.01 sec)mysql>