Difference between revisions of "MYSQL DATABASE RESTORE"
Jump to navigation
Jump to search
(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...") |
|||
| Line 45: | Line 45: | ||
ALTER USER 'username'@'%' IDENTIFIED WITH mysql_native_password BY 'password'; | ALTER USER 'username'@'%' IDENTIFIED WITH mysql_native_password BY 'password'; | ||
FLUSH PRIVILEGES; | FLUSH PRIVILEGES; | ||
---- | |||
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]] | |||
[[Category:Mysql]] | |||
Revision as of 14:19, 7 October 2025
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;