MySQL

All posts tagged MySQL

PHPMyAdmin is an useful tool for MySQL database managing. The GUI is well-known and easy to use. It is often used in a shared hosting but an out of the box version has a small disadvantage. It allows root login. We can of course set a complicated password but the problem still exists and someone who stole root’s password can easily manage our whole database server.

Continue Reading

There is a nice trick allowing to change a forgotten root password for MySQL on Debian Linux without database stopping. Just look into this file.

# cat /etc/mysql/debian.cnf 
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = u372tK6cEsTLbz0n
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = u372tK6cEsTLbz0n
socket   = /var/run/mysqld/mysqld.sock
basedir  = /usr

Simply login using this credentials and execute the query as follows.

mysql> SET PASSWORD FOR root@localhost = password('new-password');

Debian-sys-maint account was used as a backdoor ;).

Sometimes we want to see some data directly from database. MySQL command-line client allows to use external pager command like less or more. This feature is spupported by \P switch.

mysql> \P less
PAGER set to 'less'
mysql> select value from randoms;
+----------------------+
| value                |
+----------------------+
|    0.701515919250917 |
|    0.611940209392403 |
|    0.697452277594667 |
|    0.494860454923343 |
|   0.0448477035806027 |
|    0.921094222852117 |
|    0.462315713485997 |
:

MySQL client will display one page and wait for your interaction like a plain less tool.

Disabling pager:

mysql> \P
Default pager wasn't set, using stdout.
mysql>