安装配置MySQL数据库

## 安装MySQL服务 ```bash sudo apt update sudo apt install mysql-server ``` ## 设置MySQL密码 ```bash sudo mysql_secure_installation ``` ```bash sudo su mysql -u root ``` ```sql ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd'; ``` ## MySQL控制台 ```bash mysql -u root -p ``` ## 创建数据库 ```sql create database notebook CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ``` ## 创建用户以及分配权限 ```sql CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON notebook.* TO 'username'@'localhost'; FLUSH PRIVILEGES; ``` ## 查看用户权限 ```sql SHOW GRANTS FOR 'username'@'localhost'; ```