Posts for Tag: mysql

SQL query to display database size in MB

Display Mysql database size in MB Query

MySQL manage users

1. Removing users from the database.

2. Creating users – 3 common ways: A) The default way:

B) As an insert statements:

C) Batch adding users. Create a file (useradd.sql for example) which contains all create users statements :

and then execute the script:

2.1 Adding specific grants for usersRead More

Remove whitespaces from a column in MySQL database

Mysql trim function

To remove all leading and trailing whitespaces :

To remove only the trailing whitespaces :

The above example could be used to remove any character or characters from the begging or end of a text field. For more examples look into mysql function reference.

Forpsi – Cannot connect to MySQL 4.1+ using old authentication

Forpsi używa jeszcze starego mysql’a z ustawionym domyślnie old_password na On. Więc jeżeli chcemy skorzystać z bazy mysql na forpsi przy użyciu PHP 5.3 należy zalogować się do bazy i wykonać :

Reset root password for MySQL

1. First stop the MySQL service

2. Prepare w file, which contains new credentails:

3. Run the mysql_safe with the newly created file:

4. start the MySQL service

Complete guide can be found here:

Recover or Dump a Mysql databse using a commandline

Backing up MySQL database mysqldump – a quick way to dump small databases using sql files One database

All databases

Include routines,triggers and events

Gzip (compress) the backup


Recover only one database from the dump file:

Recover from a gzipped file:

Dump everything: Move one database toRead More