背景
在学习数据库的时候总是想拥有垃圾数据能够帮助我们进行SQL的练习,下面展示利用fake2db生成垃圾数据。
具体操作
开发环境: Ubuntu 18.04 Python3.8 MySQL8.0
1.安装Python3.8
$ conda create -n Python38 python=3.8
2.激活并使用Python3.8环境
$ conda activate Python38
3.安装fake2db
$ pip install fake2db
4.安装mysql的python驱动
$ pip install mysql-connector-python
5.生成垃圾数据
$ fake2db --rows 30 --db mysql --host 10.197.184.210 --password xxxxx --user root
6.查看垃圾数据
10.197.184.210 root:fake> show databases
+--------------------+
| Database |
+--------------------+
| fake |
| hello |
| information_schema |
| mysql |
| mysql_LONZXODV |
| performance_schema |
| sys |
| tianyi |
+--------------------+
8 rows in set
Time: 0.028s
10.197.184.210 root:fake> use mysql_LONZXODV
You are now connected to database "mysql_LONZXODV" as user "root"
Time: 0.000s
10.197.184.210 root:mysql_LONZXODV> show tables;
+--------------------------+
| Tables_in_mysql_LONZXODV |
+--------------------------+
| company |
| customer |
| detailed_registration |
| simple_registration |
| user_agent |
+--------------------------+
5 rows in set
Time: 0.019s