首先,我们是使用一台Linux终端来连接远程服务器上的MySql数据库,所以操作系统上需要安装客户端。
# yum install mysql
注意,书写安装的是MySQL, 可实际安装的确是MariaDB, 这后面的故事可以看看参考资料里的知乎里的一篇文章。
之后,使用命令来连接数据库。
# mysql -h 10.XXX.XXX.150 -u root -D performance_data -p
连上数据库之后,就可以在mysql shell里运行命令了。
MySQL [performance_data]> show tables;
MySQL [performance_data]> select id, automation_label, description from hardware where automation_label = ‘f8101‘;
注意,MySQL的命令之后需要输入分号,单纯的换行是不能触发命令的执行的。
参考资料
=============
YUM COMMAND CHEAT SHEET
https://access.redhat.com/sites/default/files/attachments/rh_yum_cheatsheet_1214_jcs_print-1.pdf
Yum Command Fails with “Another app is currently holding the yum lock” in CentOS/ RHEL 7
How to execute MySQL queries from command line/Bash shell ?
https://hoststud.com/resources/how-to-execute-mysql-queries-from-command-line-bash-shell.136/
How to Run MySQL/MariaDB Queries Directly from the Linux Command Line
https://www.tecmint.com/run-execute-mysql-mariadb-queries-directly-linux-commandline/
MySQL CLI Cheatsheet
https://gist.github.com/hofmannsven/9164408
CentOS 7为什么放弃了MySQL,而改使用MariaDB?