MYSQL DATABASE RESTORE

From rbachwiki
Revision as of 14:17, 7 October 2025 by Bacchas (talk | contribs) (Created page with "==Restore Database== <p style="background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;"> I used this to restore r512 from the dumped .sql file in 2025 </p> <p style="font-weight: bold;font-size: 1.3rem"> I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup. The target database must already exist. if it doesn't, create it first</p> * log into mysql CREATE DATABASE your_database_name; mysq...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Restore Database

I used this to restore r512 from the dumped .sql file in 2025

I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup. The target database must already exist. if it doesn't, create it first


  • log into mysql
CREATE DATABASE your_database_name;
mysql
use databasename;
SOURCE /path/to/file/file.sql;

Script to import a CSV File into an existing Database

The csv file has to be in a specific directory. /var/lib/mysql-files/

The table has to already exist

#!/bin/bash
mysql kartest <<EOF
truncate table songs;
load data infile '/var/lib/mysql-files/songs.csv'
into table songs
fields terminated by '|'
enclosed by '"'
lines terminated by '\n'
ignore 1 rows;
EOF

Copy csv file to a dir and run script on server

#!/bin/bash
fxcopy="/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb"
scp -i ~/.ssh/linode "$fxcopy/filename.csv" 1.1.1.1:/var/lib/mysql-files/
sleep 4
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh

Fixing error connecting to database from AppSheet

The permission has to be fixed to the old version in mysql server

ALTER USER 'username'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;