$ mysql [exec mysql client]
$ mysql db_name
[ERROR 2002 (HY000)] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
-->
$ mysql -uu13 -p [u13 is just an example username]
$ mysql -uu13 -p db_name
$ mysql -u u13 -pu13_passwd db_name
[no space allowed between -p and u13_passwd]
$ mysql --user=u13 --password=u13_passwd db_name
* chk if mysql is running
$ mysqladmin -u root -p status
$ mysqladmin -u root -p -h localhost status
*** if still error,
--> try using the local ip address (127.0.0.1) instead of 'localhost'
$ mysqladmin -u root -p -h 127.0.0.1 status
$ mysql -h 127.0.0.1 -uroot -p -t < employees.sql
[import from file employees.sql to ?]
"""...
--table, -t
Display output in table format. This is the default for interactive
use, but can be used to produce table output in batch mode.
..."""
$ mysql -u u13 -pu13_passwd -h mysql_server_host db_name
[err] mysql -h xxx.amazonaws.com:3306
[correct] mysql -h xxx.amazonaws.com -P 3306
//=== after login mysql server
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| employees |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)
mysql> use employees
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+---------------------+
| Tables_in_employees |
+---------------------+
| departments |
| dept_emp |
| dept_manager |
| employees |
| salaries |
| titles |
+---------------------+
6 rows in set (0.00 sec)
mysql> exit
~$
2015年4月1日 星期三
mysql usage examples
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言