# Issue for q2a import

**URL:** https://meta.discourse.org/t/issue-for-q2a-import/128529
**Category:** Migration
**Created:** [September 14, 2019, 12:13am UTC](https://meta.discourse.org/t/issue-for-q2a-import/128529 "2019-09-14T00:13:58Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![sat](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@sat](https://meta.discourse.org/u/sat)
#### Post date: [September 14, 2019, 12:13am UTC](https://meta.discourse.org/t/issue-for-q2a-import/128529/1 "2019-09-14T00:13:58Z")

</div>

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](https://meta.discourse.org/t/importing-from-vbulletin-4/54881)

**Docker install Server**

Steps:

1. Installed discourse using [30 min guide](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md) 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.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 14, 2019, 12:45am UTC](https://meta.discourse.org/t/issue-for-q2a-import/128529/2 "2019-09-14T00:45:43Z")

</div>

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 😉

---

<div class="post-metadata">

### Author: ![sat](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@sat](https://meta.discourse.org/u/sat)
#### Post date: [September 14, 2019, 3:39pm UTC](https://meta.discourse.org/t/issue-for-q2a-import/128529/3 "2019-09-14T15:39:24Z")

</div>

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

---

<div class="post-metadata">

### Author: ![sat](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@sat](https://meta.discourse.org/u/sat)
#### Post date: [September 15, 2019, 2:39am UTC](https://meta.discourse.org/t/issue-for-q2a-import/128529/4 "2019-09-15T02:39:03Z")

</div>

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

Thanks for your help in advance!

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 15, 2019, 2:48am UTC](https://meta.discourse.org/t/issue-for-q2a-import/128529/5 "2019-09-15T02:48:26Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![INSTAR](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/instar/32/359540_2.png) [@INSTAR](https://meta.discourse.org/u/INSTAR)
#### Post date: [October 31, 2019, 11:21am UTC](https://meta.discourse.org/t/issue-for-q2a-import/128529/6 "2019-10-31T11:21:14Z")

</div>

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](https://meta.discourse.org/t/importing-from-vbulletin-4/54881).

I also installed MariaDB instead of MySQL:

```plaintext
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:

```plaintext
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:

```plaintext
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:

```plaintext
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)

```

```plaintext
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

```

---

<div class="post-metadata">

### Author: ![INSTAR](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/instar/32/359540_2.png) [@INSTAR](https://meta.discourse.org/u/INSTAR)
#### Post date: [October 31, 2019, 12:19pm UTC](https://meta.discourse.org/t/issue-for-q2a-import/128529/7 "2019-10-31T12:19:18Z")

</div>

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

```plaintext
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:

```plaintext
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:

```plaintext
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)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [July 16, 2023, 11:34am UTC](https://meta.discourse.org/t/issue-for-q2a-import/128529/8 "2023-07-16T11:34:09Z")

</div>



---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 16, 2023, 1:55pm UTC](https://meta.discourse.org/t/issue-for-q2a-import/128529/9 "2023-07-16T13:55:50Z")

</div>


