[root@localhost ~]# systemctl start mysqld.service
[root@localhost ~]# netstat -anpt | grep 3306
tcp6 0 0 :::3306 :::* LISTEN 6662/mysqld
•访问MySQL数据库
1. 登录到MySQL服务器
经过安装后的初始化过程,MySQL数据库的默认管理员用户名为“root”,密码为空。
可以使用mysqladmin命令设置mysql的密码。
[root@localhost ~]# mysqladmin -u root -p password "123abc"
Enter password: #输入mysql的原始密码为空
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
[root@localhost ~]# mysql -u root -p #输入该命令,进入数据库
Enter password: #输入设置的密码123abc
............ #省略内容
mysql>
2.执行MySQL操作语句
(1)查看当前服务器中有哪些库
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.00 sec)
(2) 查看当前使用的库中有那些表
先使用USE语句切换到所使用的库,再用mysql> TABLES语句用于查看当前所在的库中包含的表。
mysql> use mysql; #切换到mysql库
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| engine_cost |
| event |
| func |
| general_log |
| gtid_executed |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| 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 |
+---------------------------+
31 rows in set (0.01 sec)
Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx