MYSQL DATABASE RESTORE
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;
Fix error where script to load the csv file would not execute on server=
Edit the /etc/mysql/my.cnf file
[mysqld] secure-file-priv="/var/lib/mysql-files"
you may have to add the line if it doesn't exist