scripting / Scripting-News

I'm starting to use GitHub for work on my blog. Why not? It's got good communication and collaboration tools. Why not hook it up to a blog?
119 stars 10 forks source link

Quick MySQL-on-Mac playground? #34

Open scripting opened 7 years ago

scripting commented 7 years ago

I want to get back up to speed with SQL, for an application I'm thinking of making.

I tried installing MySQL, but got in trouble because it didn't like the temporary password, and things went downhill from there.

I just want to launch an app on my Mac desktop, and be able to point the Node.js mysql package at it, and start playing.

Or use a remote server, preferably one that's free.

I'm a long way from deploying anything, this is just for play and experimenting. There must be a simple no-brainer answer, so I thought I'd ask the braintrust rather than use trial and error.

Thanks in advance! :-)

benzado commented 7 years ago

If you want a Mac GUI for talking to MySQL server, Sequel Pro is terrific and the price is nice (free).

They actually have a how-to page for installing MySQL ~that mentions an option I hadn't thought of: using Apple's macOS Server app~ (Never mind, the latest incarnation of Server doesn't include a database.) On my system, I have MySQL installed via MacPorts.

If you just want to play with SQL, you can use SQLite. None of the mess of a separate server! /usr/bin/sqlite3 is already installed on your Mac. (Doesn't Node have a single database library that can talk to either a MySQL host or an SQLite file?)

If you want a hosted MySQL server, you could use Amazon's RDS. It's very much not free, but if you're only experimenting, you'll only have to pay for a few hours of use.

scotthansonde commented 7 years ago

MAMP https://www.mamp.info/en/ is a quick and easy way to get MySQL (and Apache with PHP) going on a Mac.

scripting commented 7 years ago

Scott, I have installed MAMP before, a number of years ago, but --

  1. The website has an upsell just like the MySQL site. That makes me suspicious that there's adware baked into the software. Remember the bad old days of Windows viruses. My machines got so infected I had to reinstall the OS every couple of months.

  2. Can I access the MySQL inside the package without wanting the Apache or PHP? What I really want is MySQL without all the other stuffff. ;-)

To the others -- please read the initial message. You are asking questions that are answered there. Let's be respectful, that means reading and trying to understand before opening a reply and typing non-responsive stuff. Thanks. ;-)

scripting commented 7 years ago

Scott, I went ahead and installed MAMP, and stumbled around a bit and eventually figured out how to launch it, and get the MySQL server running. I reconfigured my Node test app to use the parameters I got from MAMP, and it says it worked.

For anyone else following this -- here's the app so far.

var mysql = require ("mysql");
var con = mysql.createConnection ({
    host: "localhost",
    port: 8889,
    user: "root",
    password: "root"
    });
con.connect (function (err) {
    if (err) {
        console.log (err.message);
        }
    else {
        console.log("Connected!");
        }
    });
scripting commented 7 years ago

Next level report.

I have it creating a database and I think adding a table. But I'm flying mostly totally blind.

There must be some kind of browser for a MySQL database? I bet that's part of MAMP...

http://localhost:8888/MAMP/index.php?page=phpmyadmin&language=English

From there you can walk around through the databases, tables, even enter queries to run against the setup. So you only have to write Node code for ops that are part of apps. Very good.

scripting commented 7 years ago

I got all that I needed working locally to being ready to start developing.

I looked at setting up a hosted MySQL database on Amazon, they ask so many questions that I have no idea how to answer, even when I clicked "Just testing" option (as opposed to provisioning for a mission critical application).

I'll probably just try to install MySQL on one of my Ubuntu servers and see what happens.

benzado commented 7 years ago

From your blog:

Also looking for a REPL, some way to issue SQL commands in the Terminal app. That must be possible, right??

I don't know where MAMP installs things, but MySQL ships with a command line tool, mysql, which does just that. If you invoke it without -p it won't prompt you for a password, it will just try to connect and fail. If you save a username and password in ~/.my.cnf you won't have to provide them on the command line every time.

scripting commented 7 years ago

A progress report. Spoiler: I'm now running MySQL on a Linux server, along with node and dropbox.

http://scripting.com/2017/10/06.html#a100640

Dave

jswright61 commented 7 years ago

Not sure where you are with things, and I'm not sure what kind of security you have set up on your DO server. I typically lock down every port but 22, 80, and 443 on my servers. MySQL listens on 3306 by default, but I DO NOT RECOMMEND leaving this port open.

I recommend creating an SSH tunnel from your local machine to your DO server - this will encrypt the traffic and you can use the same security (RSA Key) that you use to SSH to the DO server. You set up the tunnel to connect a local port (3307? or any unused local port) to 3306 on the DO server.

Any command line or gui client on your local server you set to access localhost and whatever local port (3307 from above).

Here's a pretty good explainer on port forwarding: http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html

scripting commented 7 years ago

I know about port forwarding. I left the security as it was, it only accepts requests from localhost. That seems pretty tight to me.

I can't have this become more overwhelming right now Scott. People forget how complicated this shit is once they know what they're doing. ;-)

On Fri, Oct 6, 2017 at 11:42 AM, Scott Wright notifications@github.com wrote:

Not sure where you are with things, and I'm not sure what kind of security you have set up on your DO server. I typically lock down every port but 22, 80, and 443 on my servers. MySQL listens on 3306 by default, but I DO NOT RECOMMEND leaving this port open.

I recommend creating an SSH tunnel from your local machine to your DO server - this will encrypt the traffic and you can use the same security (RSA Key) that you use to SSH to the DO server. You set up the tunnel to connect a local port (3307? or any unused local port) to 3306 on the DO server.

Any command line or gui client on your local server you set to access localhost and whatever local port (3307 from above).

Here's a pretty good explainer on port forwarding: http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and- remote-port-forwarding-explained-with-examples.html

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/scripting/Scripting-News/issues/34#issuecomment-334792448, or mute the thread https://github.com/notifications/unsubscribe-auth/ABm9O8fQLCCsYeaoZJDfGGKp8Uq90tPdks5spkpngaJpZM4Pucr4 .

andrewshell commented 7 years ago

I use https://www.sequelpro.com/ on my desktop to connect to remote SQL servers.

Here is a screenshot of how I have it configured to ssh into the server then connect to MySQL on localhost (127.0.0.1)

screen shot 2017-10-06 at 10 46 22 am

jystervinou commented 7 years ago

What @andrewshell and @benzado said. I also highly recommand Sequel Pro. You just provide the SSH credentials, and the same MySQL credentials used by your server node app.

You then have a one click access to your database (Sequel Pro remembers the credentials, and handles all the SSH tunnel and shit(*) by itself ;-) )

You can easily:

(*) sorry i'm French, is it a good word?! ;-P

scripting commented 7 years ago

So JY I know you won't mind if I figure out how to use MySQL before I do the Cadillac setup? :-)

jystervinou commented 7 years ago

Sequel Pro is indeed the Cadillac of MySQL front-ends, but with the ease of use of an autonomous car ;-)

danderson3 commented 7 years ago

In school in 1978 you probably used Ingres and Quel..., early and popular relational tools

scripting commented 7 years ago

We used Ingres! I had totally forgotten the name, but now that you mention it, it comes right back.

On Sun, Oct 15, 2017 at 7:38 AM, David E. Anderson <notifications@github.com

wrote:

In school in 1978 you probably used Ingres and Quel..., early and popular relational tools

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/scripting/Scripting-News/issues/34#issuecomment-336712143, or mute the thread https://github.com/notifications/unsubscribe-auth/ABm9O9Dx_PCMVGjf8pyq1l32k5bz9bWnks5ssgrPgaJpZM4Pucr4 .

danderson3 commented 7 years ago

The head of databases at Amazon is Mark Porter, a friend of mine. I forwarded your comments on the Aurora experience and he asked his team to address them!

scripting commented 6 years ago

Dan, that's great. Send my best wishes. They could really factor it. Make almost all the choices for you, and give you some starter code to access your database from your choice of language. Just a matter of good defaults.

When I design software, as I did with blogging, I write down the steps carefully, and then offline think about ways to eliminate steps. Iterate over it. That's how I came up with Edit This Page. 3 steps to edit. At the outset was about 20. I think the same thing could be done with an Amazon-hosted SQL database.

hasseily commented 6 years ago

Just a quick comment that you should probably look at MariaDB instead of MySQL, it's pretty much a drop-in replacement but significantly improved.