Django Models: MySQL 配置及添加数据库

2020-01-19  本文已影响0人  捞小虾

Author: Xu FC
MySQL: mysql Ver 15.1 Distrib 10.3.20-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

MySQL 配置


port                   = 3306
bind-address           = 0.0.0.0
root@kali:~# netstat -ln | more
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN 
mysqladmin -u root -p current_password password new_password
root@kali:~# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 44
Server version: 10.3.20-MariaDB-1 Debian buildd-unstable

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.001 sec)
MariaDB [(none)]> 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
MariaDB [mysql]> select user,host from user;
+------+-----------+
| user | host      |
+------+-----------+
| root | localhost |
+------+-----------+
1 row in set (0.000 sec)
MariaDB [mysql]> insert into user 
    -> (host,user,password,ssl_cipher,x509_issuer,x509_subject,authentication_string)
    -> values
    -> ('%','xufc',PASSWORD('coco'),'','','',PASSWORD('coco'));
Query OK, 1 row affected (0.000 sec)

MariaDB [mysql]> select host,user from user;
+-----------+------+
| host      | user |
+-----------+------+
| %         | xufc |
| localhost | root |
+-----------+------+
2 rows in set (0.000 sec)

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

MariaDB [mysql]> quit
Bye
MariaDB [(none)]> create database BugStatis;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> GRANT ALL privileges ON BugStatis.* TO 'xufc'@'%';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| BugStatis          |
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.001 sec)
上一篇下一篇

猜你喜欢

热点阅读