Public Access
0
0
Files
blanks/mysql/sql.md
2026-04-07 20:12:02 +00:00

32 lines
591 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Работа с базой данных через консоль
### Создаение базы данных
```sql
CREATE DATABASE db DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
```
### Создение нового пользователя
```sql
CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'password';
```
### Назначение базы для пользователя
```sql
GRANT ALL PRIVILEGES ON db.* TO 'dbuser'@'localhost';
```
### Восстановление базы из бекапа
```mysql
mysql -u root -p dbname < /tmp/dump.sql
```