# من SMF2 إلى discourse - مشاكل في استيراد المرفقات

**URL:** <https://meta.discourse.org/t/smf2-to-discourse-troubles-importing-attachments/89302>\
**Category:** Support\
**Created:** [6 يونيو 2018، 9:46م UTC](https://meta.discourse.org/t/smf2-to-discourse-troubles-importing-attachments/89302 "2018-06-06T21:46:17Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![cmwebdev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cmwebdev/32/122368_2.png) [@cmwebdev](https://meta.discourse.org/u/cmwebdev)\
**Post date:** [7 يونيو 2018، 9:27م UTC](https://meta.discourse.org/t/smf2-to-discourse-troubles-importing-attachments/89302/6 "2018-06-07T21:27:02Z")

</div>

@marcozambi I didn’t delete the VM I did this in so I was able to get the info for my fix.

The first thing I did was modify `smf2.rb`. I changed the `create_db_connection` method to the following:

```ruby
def create_db_connection
  Mysql2::Client.new(
    host: options.host,
    username: options.username,
    password: options.password,
    database: options.database,
    read_timeout: 10000,
    write_timeout: 10000,
    connect_timeout: 10000,
    reconnect: true
  )
end

```

Next, I installed MariaDB in place of MySQL. I’m not sure if this step was necessary, it was just one thing I tried while troubleshooting. I’m including it because I think some of the variables in the next step are exclusive to MariaDB, and I’m not exactly sure which setting actually solved the problem. I just went through and found all the settings dealing with timeouts, # of connections, packet size, etc. and set them at the maximum values.

Here’s a guide for replacing MySQL with MariaDB:

> **[Migrate MySQL to MariaDB on Ubuntu 24.04](https://geekrewind.com/migrate-mysql-to-mariadb-on-ubuntu-24-04/)**
>
> Migrate MySQL MariaDB on Ubuntu 24.04 with our step-by-step guide. Back up databases, verify compatibility, uninstall MySQL, and install MariaDB seamlessly.

You’ll have to import your SMF database to MariaDB after you get it setup.

Finally, add the following to the end of the `/etc/mysql/conf.d/mariadb.cnf` configuration file:

```cnf
max_allowed_packet=1073741824
connect_timeout=5000
max_connections=10000

max_length_for_sort_data=8388608
max_sort_length=8388608

net_read_timeout=10000
net_write_timeout=10000
net_retry_count=1000
net_buffer_length=1073741824

```

I believe one of these settings in the last step is what resolved it.

I think this solution will work better than the other suggestion because it makes it so the connection is never lost, as opposed to retrying the connection when it is lost.

---

_[View the full topic](https://meta.discourse.org/t/smf2-to-discourse-troubles-importing-attachments/89302)._
