Trying to get Emacs' sql-mysql
to work with an Amazon EC2.
(Technically I think this should be in superuser, but there are 10 times more Emacs questions here, so I am guessing there are more Emacs users here.)
I have successfully used ssh ec2-user@<elastic ip address>
, and from that command line, mysql -u root -p
to get a successful MySQL prompt and show databases;
. But I can't reliably get Emacs' sql-mysql
to work (I think it worked once).
So in my ignorance, I have permuted the variables about. That is, the command sql-mysql
prompts for User:
, Password:
, Database:
and Server:
.
For User:
and Password:
, I use same as I do from ssh ec2-user@<elastic ip address>
.
For Database:
, I have tried leaving it blank, but I think the time it worked I used mysql
.
For Server:
, I have tried a bunch, including
localhost
localhost@<elastic ip address>
ec2-user@<elastic ip address>
<elastic ip address>
One of the handful of error messages I get is
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
I have tried fiddling with other Emacs variables, such as default-directory
and sql-port
, but to no noticeable effect.
Additional notes:
I have tried using command line mysql
with more options, to try to mimic the same variables, ala
mysql -u root -p -h localhost@ec2-<elastic ip address>.us-west-2.compute.amazonaws.com --port=3306
but I get unknown server host.
I have seen mention of using command echo $db_host
, but I get nothing. This may be that I have only just initialized all of this.
I have also gone into AWS console and added a rule for MYSQL with port 3306 to security group.
Quick overview of the actions you need to do:
Mx sql-connect
Emacs should prompy you for a database to conect. Just type "test" (emacs will autocomplete)
(setq sql-connection-alist
'(("test"
(sql-product 'mysql)
(sql-database "your-db-name")
(sql-server "your-ec2-ip")
(sql-user "user-name")
(sql-password "password"))))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.