DEV Community

StuartCreed
StuartCreed

Posted on • Edited on

Tricks in MySQL

The following command shows you all of the processes currently running on your mysql server:
mysqladmin processlist -u username -p

Once in mysql and a database is select you can run the following to view the size and further information about your database (like the engine used on each table):
SHOW TABLE STATUS;

To change a user's password:
mysql -u root -p;
ALTER USER 'user-name'@'localhost' IDENTIFIED BY 'NEW_USER_PASSWORD';
FLUSH PRIVILEGES;

To add a new user
https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
FLUSH PRIVILEGES;

Extracting SQL file
The following would extract the database into a sql file called dump:
mysqldump databaseName > dump.sql

Top comments (0)