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)

  1. 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
    
  2. tar -zxvf mariadb-10.2.8-linux-x86_64.tar.gz

  3. 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

  4. 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 —————

  5. login root
    > mysql -u root
    
  6. set root pwd
    MariaDB [(none)]>  UPDATE mysql.user SET Password=PASSWORD('Iselecttipbot') WHERE User='root';
    
  7. derete guest user
    MariaDB [(none)]>  DELETE FROM user WHERE password="";
    
  8. Create user
    MariaDB [(none)]>  CREATE USER 'twitterbot'@'localhost' IDENTIFIED BY 'password';
    
  9. create database
    MariaDB [(none)]>  CREATE DATABASE tipnem CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
    
  10. allow the user to access DB
    MariaDB [(none)]>  GRANT all privileges ON tipnem.* TO 'twitterbot'@'localhost';
    
  11. exit
    MariaDB [(none)]>  exit
    Bye
    
  12. finish user creation

my.cnf

mysqlclient-python

mysqlclient-python を導入する必要がある。

※非常に環境によりインストール方法が異なるので注意

  1. git clone https://github.com/PyMySQL/mysqlclient-python.git

  2. find / -name mysql_config
    add to site.cfg : mysql_config =***

  3. python3 setup.py install

  4. add to setup.py : options['include_dirs'].append('/usr/local/mariadb-10.2.8-linux-x86_64/include/mysql/server')
  5. 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

  6. _mysql.c : mysql_real_escape_string_quote を使用しないようコード改変

  7. 必要ならばsocketのパスを正す : /etc/mysql/my.cnf

RETURN