我想使用Applescript在本地mysql数据库中插入值。我正在使用MAMP。
我找到了这个连接,但它不工作:(错误号-60007)
set mysql_db to "my_database"
set mysql_user to "root"
set mysql_host to "localhost"
set mysql_pw to "root"
set mysql_table to "my_table"
tell application "Finder"
# Start MAMP's Apache server
do shell script "/Applications/MAMP/bin/startApache.sh &" password mysql_pw user name mysql_user with administrator privileges
# Start MAMP's MySQL server
do shell script "/Applications/MAMP/bin/startMysql.sh > /dev/null 2>&1"
end tell如何在我的数据库中插入一些值?
发布于 2013-01-19 04:47:58
您可以使用AppleScript的do shell script语句直接调用mysql。
do shell script允许您按照从终端输入的方式执行命令脚本。然后调用mysql并向其发送命令:
(服务器正在运行时)
do shell script "/Applications/MAMP/Library/bin/mysql -u root --password=the_password \"INSERT INTO TABLE your_table (field_1, field_2) VALUES ('foo', 'bar');\" your_data_base_name"另一个(不是免费的)解决方案是使用mySql的软件Navicat,它允许从图形用户界面前端简单而有效地管理mySql数据库。它也是Apple-Scriptable。
https://stackoverflow.com/questions/14405491
复制相似问题