Delete user
mysql
DROP USER 'user'@'localhost';
List of all users
mysql
SELECT host,user,plugin,host FROM mysql.user;
Rename database
To rename database you need to create new database and dump old database into the new, you can use a script to execute this
~/bin/rename_database.sh
#!/bin/bashset -e # terminate execution on command failuremysqlconn="mysql -u root -ppassword"olddb=$1newdb=$2$mysqlconn -e "CREATE DATABASE $newdb"params=$($mysqlconn -N -e "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES \ WHERE table_schema='$olddb'")for name in $params; do $mysqlconn -e "RENAME TABLE $olddb.$name to $newdb.$name";done;$mysqlconn -e "DROP DATABASE $olddb"
sh ~/bin/rename_database.sh old_database new_database
Table of Contents