In this video, learn how to install the MySQL server on a Mac running macOS.
we'll install the MySQL Server on a Mac running macOS. This computer is running macOS Mojave. The process should be the same on any modern version of macOS. First, we need to confirm that we're not already running MySQL Server on this computer. and you'll notice that nothing is highlighted here in the System Preferences. If MySQL Server was running on this computer, there would be a little highlight around one of these items for the MySQL panel, but we don't have that, and so MySQL Server is not running on this computer. So I'm going to press Command + Q to quit the System Preferences, and now we'll go ahead, and download MySQL from the website. So here I have dev.mysql.com/downloads and I've loaded this up in my browser. I'm using Chrome. You can use any modern browser. It should work just fine. And I've got DOWNLOADS here selected and Community selected. And so, we have the MySQL Community Downloads. Now, there's several different editions of MySQL. Significantly, the Enterprise and Community editions. See, Enterprise edition cost money and if you're not running an enterprise, we're just running this for yourself, and in this case, we're just using this for development, and really just for learning so the Community edition is exactly what we want. The Community edition is free and it doesn't cost anything at all. So down here under the MySQL Community Downloads, we'll notice a couple of items. MySQL Community Server and then farther along down, MySQL Workbench. And so, I've already download both of these to my desktop, but I just want to run you though this really quickly. It's the same for both of these. When you click on this, you'll see, you'll get a page with a bunch of stuff, and then down here, have an operating system selected, in this case, macOS because I'm doing this on a Mac, and you'll have a bunch of different choices here. The DMG Archive is the easiest one. And when you press Download, you get yet another page and this page asks you to login or just sign up. If you do that, you're going to get a ton of email, most of it asking you to spend money on stuff you don't need so I didn't do that. You just press No thanks, just start my download. And you notice that when I hover over that, I get the DMG file. And so, I've already downloaded that onto my desktop here and it's right here. And I'm going to go ahead and load that. And I've also downloaded the MySQL Workbench. It's the exact same process for downloading both of them. I got both of them here on my desktop. I opened up this DMG file and I get a Mac installation package, a pkg file, and so I'll double-click on that, and I get this little warning that's going to run a program to determine et cetera. And if you've installed anything on your Mac, most of this is very familiar. It uses the standard Mac installer. So I press Continue, and I press Continue, and I accept the license agreement which I have not read. And then, I just press Install. Now, it's trying to install software. I'm going to type the password for my computer here. We're going to have different passwords involved in this process so I just want to be clear. This is the password for my computer that I'm installing this on. And I say Install. And I get this choice: Use Strong Password Encryption or Use Legacy Password Encryption. And at least for our purposes here, we want to use the Strong Password Encryption, so that we can use it. Now, the command-line interface, sometimes called the CLI. It's operated from the command line so I run Terminal, the Apple macOS Terminal program. And you notice I get this UNIX command prompt. Now, this may be intimidating for some of you if you've not used the UNIX command line before. I'm going to walk you through this, literally character by character so that we don't make any mistakes. Later, we're going to install the graphical interface, the MySQL Workbench. This step is important, especially if you want to access the command-line interface in the future, and if you're taking some of my other courses on Lynda.com or on LinkedIn, you may want to have this. But a word of warning, type very carefully. Spelling and punctuation is critical here. Just be very careful and pay close attention to every character that you type. macOS, of course, is based on UNIX. In fact, it's the largest installed base of any UNIX variant and so this is a UNIX command line. The dollar sign is where you type the command, and I'm going to type a command here, and then we're going to go back, and I'll explain it before we press Return. So follow along, but don't press Return at the end. The first word is sudo. S-U-D-O. And then, L-N, dash s, and then a forward slash. I'm just going to say slash from now on because a UNIX slash is always the forward slash. U-S-R, slash, the word local, slash, mysql, slash, the word bin, B-I-N, slash, and then msql one more time, and then a space, and then slash, U-S-R, slash, local, slash, bin. Like that. So just bit by bit, sudo is a special command that means do this as the super user or as the root user. L-N dash s is the command to create a symbolic link. It's like a file alias in UNIX. And then, this long path: usr/local/mysql/bin/mysql. That's the path through the actual MySQL command line, but we don't want to have to type that every time. We want to be able to just type mysql and that's why we're creating this symbolic link. We put it in usr/local/bin which is in the default path, execution path, and so when I press Enter here, it asks for my password and this is for sudo, and so this is my login password on my Mac. I'm going to type that in. And this is an extra precaution to protect you from doing things that you might not want to do with sudo. And so now it's done, and I should be able to just type mysql like this, and press Enter, and it's running it. And I get this Access denied because I didn't type the whole command line with the password so I type mysql, dash u, and root which is the root MySQL user we're going to be using, and dash p, and it'll prompt us for a root password. When I press Enter, it says Enter password. Now, this is the password that we gave the MySQL Server upon installation so this is the MySQL root password. I'm going to type that password here and press Enter. And here is the MySQL CLI, the command-line interface for MySQL. I have this little prompt at the bottom here where I can type a SQL command. I'ma just say show databases. It's just a simple command to make sure that the installation happened and it's all working. I press Enter and I get a result. Your result might look a little different, it might not. That's okay as long as you get a database table with a bunch of databases in it. And then you can type quit, and press Enter, and we're done. So at this point, I can press Command + Q to quit my Terminal and our installation is complete. We have now successfully installed the MySQL Server on your Mac workstation so please continue to the next lesson to install the MySQL Workbench on your Mac and that's the graphical user interface that we use in most in these courses.
- Installing MySQL on macOS, Windows, and Linux
- Installing MySQL Workbench
- Importing SQL data into MySQL
- Creating user accounts
- Managing roles
- Implementing storage engines
- Creating a new database