q2a インポートに関する問題

Question2Answer サイトをインポートしており、以下の手順に従いました。しかし、スクリプトがデータベースに接続できません。どなたかご助力ください。

参考にしたのは vBulletin スレッド です。

Docker 環境でのサーバーインストール

手順:

  1. 30 分ガイド に従って Discourse をインストールし、正常に動作することを確認しました。

  2. 以下のコマンドでアプリにログインします。
    \u003e cd /var/discourse
    \u003e ./launcher enter app

  3. MySQL のインストールがうまくいかなかったため、MariaDB をインストールしました。

\u003e apt-get update \u0026\u0026 apt-get install libmariadb-dev mariadb-server-10.3

  1. MariaDB のインストールが完了した後、ステータスを確認して起動します。

\u003e sudo service mysql status
\u003e sudo service mysql start

  1. 依存関係のインストール

\u003e echo “gem ‘mysql2’, require: false” \u003e\u003e /var/www/discourse/Gemfile
\u003e echo “gem ‘php_serialize’, require: false” \u003e\u003e /var/www/discourse/Gemfile
\u003e cd /var/www/discourse
\u003e su discourse -c ‘bundle install --no-deployment --without test --without development --path vendor/bundle’

  1. データベースのインポート

mysql -uroot -p -e ‘CREATE DATABASE q2adb’
mysql -uroot -p q2adb \u003c q2a-old-db.sql

  1. 以下の環境変数を設定しました。添付ファイルがないため、それに関連する変数は設定していません。また、root ユーザーのパスワードも設定していません。
    \u003e export DB_NAME=“q2adb”
    \u003e export DB_USER=“root”
    \u003e export DB_PW=“”
    \u003e export TABLE_PREFIX=“qa_”
    \u003e export TIMEZONE=“America/Los_Angeles”
    \u003e
    \u003e cd /var/www/discourse
    \u003e su discourse -c ‘bundle exec ruby script/import_scripts/question2answer.rb’

以下を実行した後に発生しているエラーです。

/var/www/discourse# su discourse -c ‘bundle exec ruby script/import_scripts/question2answer.rb’
root:@localhost wants q2adb
Loading existing groups…
Loading existing users…
Loading existing categories…
Loading existing posts…
Loading existing topics…

Access denied for user ‘root’@‘localhost’
Cannot connect in to database.

Hostname: localhost
Username: root
Password:
database: q2adb

スクリプトを編集するか、以下の環境変数を設定してください。

export DB_HOST=“localhost”
export DB_NAME=“”
export DB_PW=‘password’
export DB_USER=“root”
export TABLE_PREFIX=“qa_”

Exiting.

「いいね!」 1

Either you need to set a password or maybe a host name? You installed mysql inside the container?

Can you connect to mysql from the command line and see that there is data there. (Show tables :wink:

「いいね!」 3

@pfaffman

I’m inside container.

I tried setting Hostname to localhost, ‘127.0.0.1’, ip-171-22-11-150 (this is shown as a hostname when I issue command >hostname) and with actual IP address of server.

I also set password for a root users. I do see tables in db got imported correctly from q2a.

Am I missing any step?

「いいね!」 1

discourse experts, please help me on this. I dont know how to proceed at the moment.

Thanks for your help in advance!

「いいね!」 1

The traditional way to incentivize people to give you extra help is to pay money for it, you could post in marketplace with a budget.

「いいね!」 1

Hello Discourse Community,

@sat have you found a solution for this yet ?

I ran into the same error while trying to migrate from vBulletin5 using the Docker part of the same thread.

I also installed MariaDB instead of MySQL:

apt-get update && apt-get install libmariadb-dev mariadb-server-10.3

I imported my SQL data and I am able to connect to the database and see that the tables are created:

mysqlcheck -c vb5  -u root -p

At first, I used the default login (root / blank) and in a second attempt I set a password for the root user:

export DB_NAME="vb5"
export DB_USER="root"
export DB_PW="password1234"
export TABLE_PREFIX="vb5."
export ATTACHMENT_DIR='/vb5-attachments'
export TIMEZONE='Europe/Berlin'

cd /var/www/discourse
su discourse -c 'bundle exec ruby script/import_scripts/vbulletin5.rb'

I am not sure about the TABLE_PREFIX here. But all table names start with vb5. in my default installation - so I guess this should be ok (I also tried leaving it empty).

But the main issue is that I cannot connect to the MariaDB database with the discourse user:

su discourse -c 'bundle exec ruby script/import_scripts/vbulletin5.rb'
Loading existing groups...
Loading existing users...
Loading existing categories...
Loading existing posts...
Loading existing topics...
Traceback (most recent call last):
        5: from script/import_scripts/vbulletin5.rb:632:in `<main>'
        4: from script/import_scripts/vbulletin5.rb:632:in `new'
        3: from script/import_scripts/vbulletin5.rb:27:in `initialize'
        2: from script/import_scripts/vbulletin5.rb:27:in `new'
        1: from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:90:in `initialize'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:90:in `connect': Access denied for user 'root'@'localhost' (Mysql2::Error)
su discourse
mysqlcheck -c vb5  -u root -p
Enter password: #password1234
mysqlcheck: Got error: 1698: Access denied for user 'root'@'localhost' when trying to connect

Ok I am now a step closer into getting this to work. I was able to get the discourse user to connect.

  1. Connect into the Discourse container as root.
  2. Connect to the MariaDB Database
mysql -u root -p
*enter your password*
update mysql.user set plugin = 'mysql_native_password' where User='root';
FLUSH PRIVILEGES;
EXIT;

Then switch to the discourse user and try to connect to the database with the root account:

su discourse
mysql -u root -p
Enter password: #password1234

And you should see the SQL shell, when before you were getting an access denied.

Now exit the discourse user and try to run the migration script again:

exit
su discourse -c 'bundle exec ruby script/import_scripts/vbulletin5.rb'

Now the script is running (but I am getting a vBulletin5 related error I have to figure out next)