Skip to content

Instantly share code, notes, and snippets.

@NathanQ
Last active January 3, 2016 12:49
Show Gist options
  • Save NathanQ/8465658 to your computer and use it in GitHub Desktop.
Save NathanQ/8465658 to your computer and use it in GitHub Desktop.
Reference for mySQL root user pw reset, backup of server database, get and use the database on mac.
The root password is gone. Shut off mySQL, restart, and set new password:
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
mysql
>>>> UPDATE mysql.user SET Password=PASSWORD('new easy and memorable pw') WHERE User='root';
Create new one if needed:
mysql -u projectuser -p
mysql
>>>> create database projectdb;
>>>> GRANT ALL PRIVILEGES ON projectdb.* to 'projectuser'@'localhost' identified by 'password'
Create new user:
GRANT ALL PRIVILEGES ON database.* TO 'my_user'@'localhost 'IDENTIFIED BY 'password' WITH GRANT OPTION;
Create a backup of server's database:
mysqldump -u USERNAME -p DATABASE | gzip > DATABASE.thedate.sql.gz
Get the database:
scp -P port# user@server:/path/file.sql.gz /local/tmp/file.sql.gz
Port it's tables to my database
gunzip -c /local/tmp/backup.sql.gz | mysql -u projectuser -p projectdb
Delete! Delete!
mysql -u root -p
>>>> use databasename;
## drop table
>>>> drop table models_model;
## delete from table
>>>> delete from table_name where app_name = 'models';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment