Created
July 2, 2014 15:27
-
-
Save wwgist/78cc88220c141f479965 to your computer and use it in GitHub Desktop.
MYSQL: usage hints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MySQL hints | |
mysql [OPTIONS] [database] | |
mysqladmin [OPTIONS] command command.... | |
-u > user | |
-p > password | |
-D > database | |
-h > host | |
-P > port | |
-H --html > html output | |
# from command line: | |
runserver: service mysqld start (sudo /etc/init.d/mysql start) | |
stopserver: service mysqld stop | |
dumpdatabase: mysqldump -uroot -h82.82.82.82 -p database > database.sql | |
loaddatabase: mysql -uroot -h82.82.82.82 -p database < database.sql (mysql> source database.sql) | |
loadfromzip: zcat database.sql.gz | mysql -uroot -h82.82.82.82 -p database | |
# from mysql console: | |
list dbs: show databases; | |
create db: create database <dbname>; | |
delete db: drop database <dbname>; | |
connect db: use <dbname>; | |
current db: select database(); | |
list tables: show tables; | |
# reseting root password: | |
1) locate pid-file for mysqld process; | |
2) kill `cat /mysql-data-directory/host_name.pid` (backquotes) | |
3) create textfile /home/me/mysql-init (permissions for 'mysql' user to read): | |
### | |
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; | |
FLUSH PRIVILEGES; | |
### | |
4) mysqld_safe --init-file=/home/me/mysql-init & | |
5) delete /home/me/mysql-init | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment