mysql -u root -p
mysql> SELECT * FROM mysql.user;
mysql> DELETE FROM mysql.user WHERE user = ' ';
mysql> DELETE FROM mysql.user WHERE NOT (host="localhost" AND user="root");
mysql> UPDATE mysql.user SET user="mydbadmin" WHERE user="root";
mysql> GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'mypass' WITH GRANT OPTION;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON mydatabase.* TO 'username'@'localhost' IDENTIFIED BY 'mypass';
mysql> GRANT ALL PRIVILEGES ON mydatabase.* TO 'username'@'localhost' IDENTIFIED BY 'mypass' WITH GRANT OPTION;
mysql> UPDATE mysql.user SET password=PASSWORD("newpass") WHERE User='username';
mysql> DELETE FROM mysql.user WHERE user="username";
mysql> SHOW DATABASES;
mysql> CREATE DATABASE mydatabase;
mysql> USE mydatabase;
mysql> DROP DATABASE mydatabase;
$ sudo mysqlcheck -o --all-databases -u root -p
$ sudo mysqlcheck -o db_schema_name -u root -p
mysql> USE mydatabase;
mysql> SHOW TABLES;
mysql> SELECT * FROM tablename;
mysql> RENAME TABLE first TO second;
mysql> ALTER TABLE mytable rename as mynewtable;
mysql> DROP TABLE mytable;
mysql> DESC mytable;
mysql> SHOW COLUMNS FROM mytable;
mysql> UPDATE mytable SET mycolumn="newinfo" WHERE mycolumn="oldinfo";
mysql> SELECT * FROM mytable WHERE mycolumn='mydata' ORDER BY mycolumn2;
mysql> INSERT INTO mytable VALUES('column1data','column2data','column3data','column4data','column5data','column6data','column7data','column8data','column9data');
mysql> DELETE FROM mytable WHERE mycolumn="mydata";
mysql> UPDATE mytable SET column1="mydata" WHERE column2="mydata";
mysqldump -u root -pmypass --all-databases > alldatabases.sql
mysqldump -u username -pmypass databasename > database.sql
mysql -u username -pmypass < alldatabases.sql (no space in between -p and mypass)
mysql -u username -pmypass databasename < database.sql
mysqldump --no-data --databases databasename > structurebackup.sql
mysqldump --no-data --databases databasename1 databasename2 databasename3 > structurebackup.sql
mysqldump --add-drop-table -u username -pmypass databasename table_1 table_2 > databasebackup.sql
Awesome post, thanks Fredie!
That is very useful information You shared with us, FredieQO.
You're welcome!Excellent post FerdieQO
Very useful for anyone new to MySQL management.
ForumWeb.Hosting is a web hosting forum where you’ll find in-depth discussions and resources to help you find the best hosting providers for your websites or how to manage your hosting whether you are new or experienced. You’ll find it all here. With topics ranging from web hosting, internet marketing, search engine optimization, social networking, make money online, affiliate marketing as well as hands-on technical support for web design, programming and more. We are a growing community of like-minded people that is keen to help and support each other with ambitions and online endeavors. Learn and grow, make friends and contacts for life.
The world's smartest hosting providers come here to discuss & share what's trending in the web hosting world!