how to install
first of all
apt-get install build-essential git gcc python3-dev libmysqlclient-dev ufw
Install mriaDB(mariadb-10.2.8-linux-x86_64)
- get sorce
https://downloads.mariadb.org/interstitial/mariadb-10.2.8/bintar-linux-x86_64/mariadb-10.2.8-linux-x86_64.tar.gz/from/http%3A//ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/ -O mariadb-10.2.8-linux-x86_64.tar.gz
-
tar -zxvf mariadb-10.2.8-linux-x86_64.tar.gz
- check
mariadb-10.2.8-linux-x86_64/INSTALL-BINARY
shell> groupadd mysql shell> useradd -g mysql mysql shell> cd /usr/local shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf - shell> ln -s full-path-to-mysql-VERSION-OS mysql shell> cd mysql shell> chown -R mysql . shell> chgrp -R mysql . shell> scripts/mysql_install_db --user=mysql shell> chown -R root . shell> chown -R mysql data
起動コマンド
sudo /usr/local/mariadb-10.2.8-linux-x86_64/bin/mysqld_safe --user=mysql &
停止コマンドsudo /usr/local/mariadb-10.2.8-linux-x86_64/bin/mysqladmin shutdown -u root -p
- error, use apt not apt-get
Q, ./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory A, sudo apt install libaio1 libaio-dev
mariaDB / mysql —————
- login root
> mysql -u root
- set root pwd
MariaDB [(none)]> UPDATE mysql.user SET Password=PASSWORD('Iselecttipbot') WHERE User='root';
- derete guest user
MariaDB [(none)]> DELETE FROM user WHERE password="";
- Create user
MariaDB [(none)]> CREATE USER 'twitterbot'@'localhost' IDENTIFIED BY 'password';
- create database
MariaDB [(none)]> CREATE DATABASE tipnem CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
- allow the user to access DB
MariaDB [(none)]> GRANT all privileges ON tipnem.* TO 'twitterbot'@'localhost';
- exit
MariaDB [(none)]> exit Bye
- finish user creation
my.cnf
mysqlclient-python
mysqlclient-python を導入する必要がある。
※非常に環境によりインストール方法が異なるので注意
-
git clone https://github.com/PyMySQL/mysqlclient-python.git
-
find / -name mysql_config
add to site.cfg :mysql_config =***
-
python3 setup.py install
- add to setup.py :
options['include_dirs'].append('/usr/local/mariadb-10.2.8-linux-x86_64/include/mysql/server')
-
add to ~/.bashrc :
export LD_LIBRARY_PATH=/usr/local/mariadb-10.2.8-linux-x86_64/lib
export PATH=/usr/local/mariadb-10.2.8-linux-x86_64/bin:$PATH
-
_mysql.c :
mysql_real_escape_string_quote
を使用しないようコード改変 - 必要ならばsocketのパスを正す :
/etc/mysql/my.cnf