I'm not really a fan of MySQL but here is a simple problem I always forget the syntax for which is really a SQL issue.
An installation of MediaWiki has an update script which requires the DROP privilege on the database, so I wanted to add the DROP privilege, run the update script and revoke the DROP privilege again.
Here's how:
mysql> show grants for 'username'@'host';
mysql> grant drop on adatabase.* to 'username'@'host';
mysql> revoke drop on adatabase.* from 'username'@'host';
Job's a good-un!
Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts
Wednesday, 18 August 2010
Wednesday, 23 September 2009
Formatting Output from MySQL prompt
I'm not the biggest fan of MySQL and on the occasions I do use it I always forgot how to get useful results from my queries. To get results paged to less and have them display vertically, you can do this
mysql> \P less
PAGER set to 'less'
mysql> select * from blahblah \G
mysql> \P less
PAGER set to 'less'
mysql> select * from blahblah \G
Restore Mysql Database from the .frm .MYI and .MYD files
OK so you have a mysql database that you have recovered from a backup. However, whereas you would normally have a nice sql dump to deal with, on this occasion you only have the .frm .MYI and .MYD files. Can you rescue that table the client has deleted? Indeed you can!
#> cd [where you databases are kept, possibly /var/lib/mysql ]
#> mkdir [name of database to rescue]
copy the .frm .MYI and .MYD files into it.
make sure the permissions are ok. Something like this
#> chown -R mysql:mysql [dbname]
#> chmod -R 700 [dbname]
Now if you are lucky, you should be able to do this:-
#> mysql -u root databasename -e "SHOW TABLES;";
#> mysqldump -u root databasename tablename
#> cd [where you databases are kept, possibly /var/lib/mysql ]
#> mkdir [name of database to rescue]
copy the .frm .MYI and .MYD files into it.
make sure the permissions are ok. Something like this
#> chown -R mysql:mysql [dbname]
#> chmod -R 700 [dbname]
Now if you are lucky, you should be able to do this:-
#> mysql -u root databasename -e "SHOW TABLES;";
#> mysqldump -u root databasename tablename
Subscribe to:
Posts (Atom)