鏈接mysql數據庫python
mysql -u root -p 123456
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| python |
| sys |
+--------------------+
5 rows in set (0.00 sec)mysql
mysql> use mysql;
Database changedsql
mysql> show tables; +---------------------------+ | Tables_in_mysql | +---------------------------+ | columns_priv | | component | | db | | default_roles | | engine_cost | | func | | general_log | | global_grants | | gtid_executed | | help_category | | help_keyword | | help_relation | | help_topic | | innodb_index_stats | | innodb_table_stats | | password_history | | plugin | | procs_priv | | proxies_priv | | role_edges | | server_cost | | servers | | slave_master_info | | slave_relay_log_info | | slave_worker_info | | slow_log | | tables_priv | | time_zone | | time_zone_leap_second | | time_zone_name | | time_zone_transition | | time_zone_transition_type | | user | +---------------------------+ 33 rows in set (0.02 sec)
mysql> desc user;
mysql> select * from user; 豎列顯示,注意後面沒有分號 mysql> select * from user\G
mysql> quit;
Mysql安裝成功後,默認的root用戶密碼爲空,可使用下面的命令建立root用戶的密碼:數據庫
mysqladmin -u root password "new password"
use test; show tables; grant all on test.* to 'alex'@'%' identified by 'alex3714' use mysql; select * from user\G show grants for alex;