-
Notifications
You must be signed in to change notification settings - Fork 3
Getting started Piwidict
Andrew Krizhanovsky edited this page May 2, 2019
·
12 revisions
Let's import the parsed Wiktionary database into local MySQL database.
And let's provide an access to this database from PHP-code.
Create root password in MySQL:
sudo mysql -u root
mysql$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Download the latest file with database from Wikokit. Select Russian Wiktionary or English Wiktionary. Unzip it, e.g. to:
/ruwikt20160210_parsed.sql
$ mysql -u root -p
mysql$ CREATE DATABASE ruwikt20160210_parsed;
mysql$ USE ruwikt20160210_parsed;
mysql$ CHARSET binary;
mysql$ SOURCE /ruwikt20160210_parsed.sql
Open the folder piwidict/src/examples
.
Copy the example config_password_example.php
file to config_password.php in the same folder piwidict/src/examples
:
cp ~/piwidict/src/examples/config_password_example.php ~/piwidict/src/examples/config_password.php
Replace 'pass1' and 'pass2' by your passwords:
$config['user_login'] = 'pw_user';
$config['user_password'] = 'pass1';
$config['admin_login'] = 'pw_admin';
$config['admin_password'] = 'pass2';
Piwidict works with two users in MySQL:
- pw_user can read information from the database;
- pw_admin can edit the database.
Add users to the MySQL database. Grant privileges at database levels. Open MySQL command-line and run commands:
mysql>
DROP user 'pw_user'@'localhost';
DROP user 'pw_admin'@'localhost';
CREATE USER 'pw_user'@'localhost' IDENTIFIED BY 'pass1';
CREATE USER 'pw_admin'@'localhost' IDENTIFIED BY 'pass2';
GRANT SELECT ON ruwikt20160210_parsed.* TO pw_user@'localhost' identified by 'pass1';
GRANT SELECT, INSERT, UPDATE, CREATE, DROP, INDEX ON ruwikt20160210_parsed.* To 'pw_admin'@'localhost' IDENTIFIED BY 'pass2';
FLUSH PRIVILEGES;
Class map generation:
composer dump-autoload --optimize