Archive for the ‘MySQL’ Category
mbstring PHP extension was not found
I was getting an error message when I accessed phpMyAdmin. The error was:
"The mbstring PHP extension was not found and you seem to be using a multibyte charset. Without the mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results.
"
This error means that mbstring PHP extension is not enabled or installed. In my case it was not enabled.
To resolve this I had to enable it in my php.ini file. Open your php.ini file and un-comment these lines:
- extension=php_mbstring.dll
- extension=php_mysql.dll
- extension=php_mysqli.dll
Restart your Linux server and this error will go away.
Automatically backup MySQL database
I needed to backup a couple of MySQL databaes automatically. Here is what I did to accomplish this.
I created a folder called mysqlbackup. I then created a script called ”mysqldbbackup.sh” and put this script file in the mysqlbackup folder.
It contains “rm /mysqlbackup/DBNAME_backup.sql
mysqldump -u USERNAME -pPASSWORD DBNAME > /mysqlbackup/DBNAME_backup.sql”
I used the “rm” command to remove the last database backup before the new backup runs. For one of my old blogs on mysqldump command click here.
You have to make the script executable. To do this use the following command
“chmod +x /mysqlbackup/mysqldbbackup.sh”
Now test your script to make sure it works. CD to the mysqlbackup directory and run the script using by typing “mysqldbbackup.sh”
Ok after it works you need to now schedule it. Use cron to schedule it. I set it to run ever Tuseday at 3am. Use this command to set it via cron “0 3 * * 2 /mysqlbackup/mysqldbbackup.sh”
For more on cron visit ABOUT CRONJOBS . For more about Linux Shell scripst visit LINUX BASH SHELL SCRIPT
Backup MySQL DB in command line
So you have a website on a dedicated server. You need to backup a database. You tried to backup through PhPMyadmin but it keeps timing out. Here is what you need to do. Backup the database through a terminal session. SSH into your web/MySQL server and run the following commands below.
TO BACKUP:
##Without G Zip Compresssion:
mysqldump -u USERACCOUNT -pYOURPASSWORDGOESHERE YOURDATABASENAMEHERE > latest_backup_061009.sql
##With G Zip Compresssion:
mysqldump -u USERACCOUNT -pYOURPASSWORDGOESHERE YOURDATABASENAMEHERE | gzip -c > latest_backup_061009.sql
TO RESTORE:
##To restore a backup of a database created with mysqldump, you will need to use the mysql command. If your SQL dump file doesn’t contain any “create database” statement use the following command:
mysql -u USERACCOUNTNAME -pYOURPASSWORDGOESHERE YOURDATABASENAMEHERE < latest_backup_061009.sql
##But if it does contain the “create database” statement use the same command without specifying the database name:
mysql -u USERACCOUNTNAME -pYOURPASSWORDGOESHERE < latest_backup_061009.sql



