SeleniumBase/help_docs/mysql_installation.md

61 lines
1.9 KiB
Markdown
Raw Normal View History

2016-02-13 15:58:01 +08:00
### MySQL Installation Instructions
#### [MySQL](http://www.mysql.com/) (OPTIONAL)
(NOTE: If you're using this test framework from a local development machine and don't plan on writing to a MySQL DB from your local test runs, you can skip this step.)
2019-08-18 05:03:33 +08:00
##### Linux (Ubuntu):
2016-02-13 15:58:01 +08:00
```bash
2019-08-18 05:03:33 +08:00
sudo apt update
sudo apt install mysql-server
sudo mysql_secure_installation
sudo mysql -e 'CREATE DATABASE IF NOT EXISTS test_db;'
sudo mysql -h 127.0.0.1 -u root test_db < seleniumbase/core/create_db_tables.sql
sudo service mysql restart
2016-02-13 15:58:01 +08:00
```
2019-08-18 05:03:33 +08:00
To change the password:
```bash
mysqladmin -u root -p'OLD_PASSWORD' password NEW_PASSWORD
sudo service mysql restart
```
2016-02-13 15:58:01 +08:00
2019-08-18 05:03:33 +08:00
##### MacOS:
```bash
brew install mysql
```
2019-08-18 05:03:33 +08:00
Then you'll need to start the MySQL service:
```bash
2019-08-18 05:03:33 +08:00
brew services start mysql
```
2019-08-18 05:03:33 +08:00
Continue with additional steps below to setup your DB.
##### Windows:
[Download MySQL here](http://dev.mysql.com/downloads/windows/)
Follow the steps from the MySQL Downloads page.
Continue with additional steps below to setup your DB.
2016-02-14 03:59:16 +08:00
#### Access your MySQL DB
2016-02-13 15:58:01 +08:00
If you want a visual tool to help make your MySQL life easier, [try MySQL Workbench](http://dev.mysql.com/downloads/workbench/).
2016-02-14 03:59:16 +08:00
#### Prepare your MySQL DB
2020-02-18 15:10:36 +08:00
You can use the [create_db_tables.sql](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/core/create_db_tables.sql) file to create the necessary tables for storing test data.
2016-02-14 03:59:16 +08:00
#### Configure your MySQL DB for SeleniumBase
You'll want to update your [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) file with your MySQL DB credentials so that tests can write to the database when they run.
2016-02-14 03:59:16 +08:00
#### Allow tests to write to your MySQL database
Add the ``--with-db_reporting`` argument on the command line when you want tests to write to your MySQL database.
Example:
```bash
2019-04-14 17:05:21 +08:00
pytest my_first_test.py --with-db_reporting
2016-02-14 03:59:16 +08:00
```