To restore a database backup with we can used the SQL command next:
CREATE DATABASE [dbname]; -- Create a database (If it was created is not necessary)
RESTORE DATABASE [dbname]
FROM DISK = ‘PATH_OF_THE_BACKUP’ -- Path of the backup file
WITH REPLACE,
MOVE ‘dbname_Data’ TO ‘DEST_PATH/dbname_Data.MDF’, -- File Path database or where we put
MOVE ‘dbname_Log’ TO ‘DEST_PATH/dbname_Log.LDF’ -- Same as above but for the log
This can be done from SQL Query Analyzer or any applications that do allow us to execute sentiencias SQL on database.
NOTE: Sorry for my english, but i am learning. I accept corrections.
(NOTE: was migrated of the old site)
On occasions it happens that the name of the database or backup do not correspond to the ID of database contained in backup, for example, our database is called SYS, but when it was created is called SYS-SA, therefore the initial names of the data and logs files were SYS_SA_Data and SYS_SA_Log.
If we try to restore we need know these names files, for this we can use the following SQL statment, that show this information and which also gives us the type, size and maximum size of the database.
RESTORE FILELISTONLY
FROM DISK = 'PATH_OF_THE_BACKUP' -- this is the backup file path
NOTE: Sorry for my english, but i am learning. I accept corrections.
(NOTE: was migrated of the old site)
If you see the next message “The log file for database ‘tempdb’ is full.”, or if you only want empty the log of each database, you can do the next.
Open the SQL Query Analyzer
and run this:
BACKUP LOG <"database_name"> WITH TRUNCATE_ONLY
GO
NOTE: Sorry for my english, but i am learning. I accept corrections.
(NOTE: was migrated of the old site)
On many occasions, I forgot the password of the user Administrator (root) of me Mysql server, may be that Why was not the administrator?, but good if you get local access to the system, you can use the following instructions, to obtain the administrator access.
Option 1:
#the easiest is run mysqladmin using the following instruction.
"Mysql Path" /mysqladmin -u root password "new password" #without quote
#where the common path on windows system is:
c:\mysqlbin or c:\Archivos de programa\mysql\bin
#on linux system is:
/usr/bin or /usr/local/bin or (sbin) in some case.
Option 2:
#Other option is stop the mysql service using:
mysql stop
#after, open mysql on safe mode:
safe_mysql --skip-grant-table &
#run the mysql client and update the user table on db mysql changing the user password.
$ USE mysql;
$ UPDATE user SET password=PASSWORD('new password') WHERE user='root';
$ flush privileges;
get out using “exit” on the client and restart the mysql service.
the first options is most recommendable, but in occasions is better to have alternatives.
NOTE: Sorry for my english, but i am learning. I accept corrections.
(NOTE: was migrated of the old site)