43 lines
1009 B
Markdown
43 lines
1009 B
Markdown
### Create `photos` user for DB
|
|
|
|
You will need to know the root password for your mariadb installation. If you
|
|
need to reset the root password, you can perform the following:
|
|
|
|
```bash
|
|
export PASSWORD=m4g1cP4ssw0rd
|
|
sudo service mysql stop
|
|
sudo mysqld_safe --skip-grant-tables &
|
|
sleep 1 # mysqld_safe can take a bit of time to come online
|
|
sudo mysql << EOF
|
|
use mysql;
|
|
UPDATE user SET PASSWORD=PASSWORD("${PASSWORD}") WHERE USER='root';
|
|
UPDATE user SET plugin='mysql_native_password' WHERE USER='root';
|
|
FLUSH PRIVILEGES;
|
|
QUIT
|
|
EOF
|
|
sudo service mysql stop
|
|
sudo service mysql start
|
|
```
|
|
|
|
Once you know the root password, you can then create a new user and DB
|
|
for the photo app via:
|
|
|
|
### Create the USER
|
|
|
|
```bash
|
|
U=photos
|
|
P=p4$$w0rd
|
|
mysql -u root --password=${PASSWORD} << EOF
|
|
GRANT ALL PRIVILEGES ON *.* TO '${U}'@'localhost' IDENTIFIED BY '${P}';
|
|
EOF
|
|
```
|
|
|
|
```bash
|
|
D=photos
|
|
mysql -u ${U} --password=${P} << EOF
|
|
DROP DATABASE IF EXISTS ${D};
|
|
CREATE DATABASE ${D} CHARACTER SET utf8 COLLATE utf8_general_ci;
|
|
EOF
|
|
```
|
|
|