Issue for q2a import

I’m importing question2answer site and followed below steps. Script is not able to connect to db. anyone please help me on this.

I took ref from vBulletin thread

Docker install Server

Steps:

  1. Installed discourse using 30 min guide and it worked perfectly fine.
  2. entered app using below commands

cd /var/discourse
./launcher enter app

  1. Installed Mariadb as I was not able to install mysql:

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

  1. After finishing installing Mariadb check its status and started:

sudo service mysql status
sudo service mysql start

  1. Install dependencies

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

  1. Imported database

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

  1. exported below variables, I dont have any attachments so not exported that variable. also not set password for root user.

export DB_NAME=“q2adb”
export DB_USER=“root”
export DB_PW=“”
export TABLE_PREFIX=“qa_”
export TIMEZONE=“America/Los_Angeles”

cd /var/www/discourse
su discourse -c ‘bundle exec ruby script/import_scripts/question2answer.rb’

This is the error I’m getting now after running below command.

/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

Edit the script or set these environment variables:

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

Exiting.

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:

@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?

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

Thanks for your help in advance!

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.

Discourse 커뮤니티 여러분,

@sat 님, 이 문제에 대한 해결책을 찾았나요?

저도 같은 스레드의 Docker 부분을 사용하여 vBulletin5에서 마이그레이션을 시도하다가 동일한 오류를 겪었습니다.

또한 MySQL 대신 MariaDB를 설치했습니다:

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

SQL 데이터를 가져왔고, 데이터베이스에 연결하여 테이블이 생성되었음을 확인할 수 있습니다:

mysqlcheck -c vb5  -u root -p

처음에는 기본 로그인(root / blank)을 사용했고, 두 번째 시도에서는 root 사용자에게 비밀번호를 설정했습니다:

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'

여기서 TABLE_PREFIX 값이 정확한지 확신이 서지 않습니다. 하지만 제 기본 설치 환경에서는 모든 테이블 이름이 vb5.로 시작하므로, 이렇게 설정하는 것이 맞을 것 같습니다(빈 값으로 두는 것도 시도해 보았습니다).

하지만 주요 문제는 discourse 사용자로 MariaDB 데이터베이스에 연결할 수 없다는 점입니다:

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

음, 이제 이 문제를 해결하는 데 한 발짝 더 가까워졌네요. Discourse 사용자가 연결되도록 성공적으로 설정했습니다.

  1. root로 Discourse 컨테이너에 접속합니다.
  2. MariaDB 데이터베이스에 연결합니다.
mysql -u root -p
*비밀번호 입력*
update mysql.user set plugin = 'mysql_native_password' where User='root';
FLUSH PRIVILEGES;
EXIT;

이제 discourse 사용자로 전환하여 root 계정으로 데이터베이스에 연결을 시도해 보세요:

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

이전에는 액세스가 거부되었지만, 이제 SQL 셸이 표시되어야 합니다.

이제 discourse 사용자에서 종료하고 마이그레이션 스크립트를 다시 실행해 보세요:

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

이제 스크립트가 실행되고 있습니다(하지만 다음 단계에서 해결해야 할 vBulletin5 관련 오류가 발생하고 있습니다).