连接mysql数据库
mysql -u root -p 123456
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| python |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> use mysql;
Database changed
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 userG
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 userG show grants for alex;