MySQL / MariaDB

Mariadb forked from MySQL when Oracle bought MySQL, so I use MariaDB. The XAMPP controller that establishes localhost for developing uses MariaDB.

sudo apt install mariadb-server

sudo apt install libmariadb3 libmariadb-dev python3-dev

(I don’t think this was necessary) Enable mysqli in /etc/php/7.2/apache2/php.ini by removing comment ‘;’

extension=mysqli ; nate enabled this

also:

sudo phpenmod mysql

To login to MySQL from the Linux command prompt:

sudo mysql -u root or mysql -u username -p

From the MySQL command prompt, which is “MariaDB” – a version of MySQL, same thing, various self-explanatory commands:

MariaDB [(none)]> CREATE user 'new_username'@'localhost';

SELECT user, host, authentication_string FROM mysql.user;

DROP user 'new_username'@'localhost'

CREATE USER 'new_username'@'localhost' IDENTIFIED BY 'yourpassword';

CREATE database yourdatabasename;

GRANT SELECT, INSERT, UPDATE ON yourdatabasename.* TO 'new_username'@'localhost';

or

GRANT ALL ...

SHOW GRANTS FOR new_username;

ALTER USER 'new_username'@'localhost' IDENTIFIED BY 'yournewpassword';

SHOW DATABASES;

USE yourdatabasename;

CREATE table

FLUSH PRIVILEGES not required if privileges were added with the GRANT command.

Connect to MariaDB Remotely

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

and change the bind-address line to:

bind-address = 0.0.0.0

Connect to MariaDB with Python

https://mariadb.com/resources/blog/how-to-connect-python-programs-to-mariadb

https://mariadb.com/docs/server/connect/programming-languages/c/install/#Installation_via_Package_Repository_(Linux)

sudo apt install libmariadb3 libmariadb-dev

sudo apt install build-essential libssl-dev libffi-dev python3.13-dev

pip3 install mariadb

https://mariadb.com/resources/blog/how-to-connect-python-programs-to-mariadb