Differences between revisions 1 and 2
Revision 1 as of 2009-06-27 19:57:09
Size: 1753
Editor: SamatJain
Comment:
Revision 2 as of 2009-06-27 19:58:42
Size: 1754
Editor: SamatJain
Comment:
Deletions are marked like this. Additions are marked like this.
Line 77: Line 77:
Source: [[http://jeremy.zawodny.com/blog/archives/011120.html|Jeremy Zawodny: MySQL and Drizzle Tip: Checking configuration file syntax (faking configtest)]] Source: [[http://jeremy.zawodny.com/blog/archives/011120.html|Jeremy Zawodny's MySQL and Drizzle Tip: Checking configuration file syntax (faking configtest)]]

Backup and restore

Backing up tables:

   1 mysqldump -p -c -Q databasename tablename1 tablename2 ... > whatever.sql

Restoring tables:

   1 mysql -p databasename < whatever.sql

Creating a user with their own database

   1 CREATE DATABASE dbname;
   2 GRANT USAGE ON dbname.* TO username@'%';
   3 GRANT ALL ON dbname.* TO username@'%';
   4 SET PASSWORD FOR username@'%' = PASSWORD('blah');
   5 FLUSH PRIVILEGES;

Changing passwords

   1 SET PASSWORD = PASSWORD('blah');

Changing adminstrator password

   1 mysql -u root
   2 mysql> SET PASSWORD FOR root@localhost = PASSWORD('new_password');

Disabling network access

In my.cnf, add to the [mysqld] section:

skip-networking
bind-address=127.0.0.1

Flushing the initial database and users

   1 drop database test;
   2 use mysql;
   3 delete from db;
   4 delete from user where not (host="localhost" and user="root");
   5 flush privileges;

Deleting users

   1 REVOKE ALL PRIVILEGES ON *.* FROM username@'%';
   2 REVOKE GRANT OPTION ON *.* FROM username@'%';
   3 DELETE FROM mysql.user WHERE (User='username' and Host='%');

Notes

  • When specifying hosts from which users may login, '%' means any host. These have precedence over 'localhost'

Checking configuration without starting up MySQL

   1 mysqld --defaults-file=/tmp/new.cnf --verbose --help

Source: Jeremy Zawodny's MySQL and Drizzle Tip: Checking configuration file syntax (faking configtest)


CategoryCheetSheet

SamatsWiki: CheatSheet/MySQL (last edited 2018-07-18 10:24:19 by SamatJain)