How to Recover MySQL Root PasswordJanuary 17th, 2009 Do you want to recover the MySQL root password. its by no means, easy.
How to Update or Change Password for a Single User in MySQL and Reload PrivilegesJanuary 17th, 2009 MySQL stores usernames and passwords in the user table inside the MySQL database. You can directly update a password using the following method to update or change passwords:
1) Login to the MySQL server, type the following command at the shell prompt:
$ mysql -u root -p
2) Use the mysql database (type commands at the mysql> prompt):
mysql> use mysql;
3) Change password for a user:
mysql> update user set password=PASSWORD("newpass") where User='YOUR-USER-NAME';
4) Reload privileges:
mysql> flush privileges;
mysql> quit
[P.S.
How to Move the MySQL data directory in UbuntuJanuary 6th, 2009 MySQL data directory is the most important and sensitive place for any administrator. How do you move the whole data directory all on a sudden? There is no particular topic in the internet writing about it clearly.
Solution: MySQL Master-Master Replication Fails With ERROR 1200 (HY000) on MasterNovember 16th, 2007 When you try MySQL master-master replication with two (or more) servers you may often find that in the process of configuring the original master to also act as a slave server (start slave), it fails with the following error:
mysql> start slave;
ERROR 1200 (HY000): The server is not configured as slave; fix in config file or with CHANGE MASTER TO
To rectify it locate and delete the master.info file and restart the mysql server. Now try to start slave and it should work.
How To Migrate Mantis Defect Tracking System From Windows To Linux / Fedora Core 6May 12th, 2007 Mantis is popular php based defect tracking application which works on top of RDBMS like MySQL and PostgreSQL. Recently I ported our Windows based Mantis installation to Linux.
How to start/stop MySQL server on LinuxJanuary 7th, 2005 # To Start MySQL Server
/sbin/service mysqld start
# To Stop MySQL Server
/sbin/service mysqld stop
# To Restart MySQL Server
/sbin/service mysqld restart
And of course there is the brute force way to kill all the processes:
$ for i in `ps -ef |grep mysqld |awk '{print $2}'`; do `kill -9 $i`; done
Thanks to Anthony Eden for the comment (below) to remove the dot in front. A simpler alternative is:
pkill mysqld
This will kill the mysqld process.
How to Backup & Restore MySQL DatabaseMay 13th, 2005 Note: My WordPress database name is wordpress. I will use it in the example below.
Sun Restricts MySQL Query Analyzer Tool To Gold Subscribers OnlyNovember 25th, 2008 The MySQL Query Analyzer tool monitors query performance and quickly pinpoints and corrects problems in SQL code. It promises to "turbo-boost" the speed and uptime of MySQL database applications.
How To Test Master-Master / Master-Slave / Standard / Circular Replication on MySQLSeptember 1st, 2007 Working with replication systems is not easy. Learning and testing different kind of MySQL replications and fine-tuning it to your specific needs is a time-consuming endeavor.
How do I Enable Remote Access To MySQL Database?April 27th, 2009 Suppose you want to change and enable the remote access to MySQL DB on your linux server (Debian). By default, you don't get such privileges so you will have to work your way through this.
MySQL High End Features Should be Closed Source & for Paid Customers OnlyApril 18th, 2008 I am serious. While MySQL is a great open source database, I have full respect to Sun's plan to provide high-end features for paying customers only.
How To Export MS Access Database To MySQL DatabaseAugust 30th, 2008 Here are few tips (with undocumented features) to help you export huge MS Access database (production database with real data) to MySQL. Use mdbtools utilities as described below:
mdb-tables displays the list of tables in MS Access
mdb-scheme export the MS Access schema to MySQL database.
Tip: How To Find MySQL VersionSeptember 1st, 2007 Try:
mysql -e status|grep 'Server version'
If that doesn't work then use:
mysql -u root -p -e status|grep 'Server version'
Provide root password when prompted. Default root password for MySQL is empty string, so just pressing enter when prompted for password will suffice by default.
How To Enable/ Disable Auto Reconnect in MySQLJuly 20th, 2007 What is auto reconnect in MySQL?
The MySQL client library can perform an automatic reconnect to the server if it finds that the connection is down when you attempt to send a statement to the server to be executed. In this case, the library tries once to reconnect to the server and send the statement again.
6 MySQL Database Replication TipsNovember 18th, 2007 Replicating on two or more MySQL master database servers
1. MySQL Master-Master Replication Fails With ERROR 1200 (HY000) on Master
2.
March 20th, 2008 at 3:06 pm
Aca va una clase que les puede ayudar un poco
class FechasMysql
{
const _formatoTimeStampMysql='Y-m-d H:i:s';
const _formatoFechaMysql='Y-m-d';
const _formatoHoraMysql='H:i:s';
const _separadorFechaHoraMysql=' ';
const _separadorFechaMysql='-';
const _separadorHoraMysql=':';
const _pocisionFechaEnTimestamp=0;
const _pocisionHoraEnTimestamp=1;
const _zonaUtc='America/Bogota';
const _zonaIdioma='esl';
/**
* Convierte el timestamp de unix a timestamp de mysql
*
* @param int[optional] timestamp de unix por defecto el actual
* @return string timestamp de Mysql con formato FechasMysql::_formatoTimeStampMysql
*/
public static function MySqlTimeStamp($unixTimestamp=null)
{
FechasMysql::ConfigurarZona();
if ($unixTimestamp===null)
$unixTimestamp=time();
return date(FechasMysql::_formatoTimeStampMysql,$unixTimestamp);
}
/**
* Convierte el timestamp de unix a time de mysql
*
* @param[optional] int timestamp de unix por defecto el actual
* @return string time de Mysql con formato ‘H:i:s’
*/
public static function MySqlTime($unixTimestamp=null)
{
FechasMysql::ConfigurarZona();
if ($unixTimestamp===null)
$unixTimestamp=time();
return date(FechasMysql::_formatoHoraMysql,$unixTimestamp);
}
/**
* Convierte el timestamp de unix a date de mysql
*
* @param int[optional] timestamp de unix por defecto el actual
* @return string date de Mysql con formato ‘Y-m-d ‘
*/
public static function MySqlDate($unixTimestamp=null)
{
FechasMysql::ConfigurarZona();
if ($unixTimestamp===null)
$unixTimestamp=time();
return date(FechasMysql::_formatoFechaMysql,$unixTimestamp);
}
/**
* Obtiene El string de la fecha
*
* @param int[optional] timestamp de unix por defecto el actual
* @param string[optional] opcion si ‘F’ retorna la fecha, por defecto; de lo contrario Fecha y Hora
* @return string fecha o fecha y hora en una cadena
*/
public static function ObtenerStringFechaUnix($unixTimestamp=null,$opcionString=’F')
{
FechasMysql::ConfigurarZona();
if ($unixTimestamp===null)
$unixTimestamp=time();
if ($opcionString==’F')
return strftime(’ %A, %d de %B de %Y.’ ,$unixTimestamp);
else
return strftime(’ %H:%M del %A, %d de %B de %Y.’ ,$unixTimestamp);
}
/**
* Obtiene El string de la fecha
*
* @param String[optional] timestamp de Mysql por defecto el actual
* @param string[optional] opcion si ‘F’ retorna la fecha, por defecto; de lo contrario Fecha y Hora
* @return string fecha o fecha y hora en una cadena
*/
public static function ObtenerStringFechaMysql($mysqlTimeStamp=null,$opcionString=’F')
{
if ($mysqlTimeStamp===null)
$mysqlTimeStamp=date(FechasMysql::_formatoTimeStampMysql);
$unixTimestamp=FechasMysql::UnixTimeStamp($mysqlTimeStamp);
return FechasMysql::ObtenerStringFechaUnix($unixTimestamp,$opcionString);
}
/**
* Convierte el timestamp de mysql a timestamp de unix
*
* @param string timestamp de Mysql con formato ‘Y-m-d H:i:s’ por defecto el actual
* @return int timestamp de unix
*/
public static function UnixTimeStamp($mysqlTimeStamp)
{
FechasMysql::ConfigurarZona();
$arrayTimestamp=explode(FechasMysql::_separadorFechaHoraMysql, $mysqlTimeStamp);
$arrayFecha = explode(FechasMysql::_separadorFechaMysql,$arrayTimestamp[FechasMysql::_pocisionFechaEnTimestamp]);
$arrayHora=explode(FechasMysql::_separadorHoraMysql,$arrayTimestamp[FechasMysql::_pocisionHoraEnTimestamp]);
return $unixTimesTamp = mktime($arrayHora[0],$arrayHora[1],$arrayHora[2],$arrayFecha[1],$arrayFecha[2],$arrayFecha[0]);
}
private static function ConfigurarZona()
{
//se asegura que la zona horaria adecuada
date_default_timezone_set(FechasMysql::_zonaUtc);
//Pone el idioma
setlocale(LC_TIME,FechasMysql::_zonaIdioma);
}
}
June 1st, 2009 at 8:42 pm
There’s a much easier way
Don’t bother using UNIX_TIMESTAMP(`when`)
You can always do this:
$sPHPDate = date(’whatever format u want’,strtotime($aRowFromDbResult['when']));
strtotime is exceptionally clever it can parse a wide variety of date formats including MySQL’s default date and timestamp format
http://php.net/strtotime
June 23rd, 2009 at 8:18 pm
AGREED WITH PHPSLACKER
July 30th, 2009 at 5:42 am
thanks PHPSLAKER !!! it totally worked..