alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
The first line of this example enables the main drive of the Mac machine. The name of the drive on which you locate MySQL may be different on your server. The second line
changes the owner to the user mysql. The last two lines create aliases for the two key MySQL clients mentioned earlier so that you can run them from anywhere on your system.
At this point, you should be able to start the daemon and log into MySQL or MariaDB. If you installed the preference pane for MySQL with the installer, you can go to the Systems Preference of the operating system and start it there instead:
sudo /usr/bin/mysqld_safe &
mysql -u root -p
Depending on the release of MySQL, the file path for a dmg installation may be different from what is shown in the first line here. An ampersand (&) sends the process to the background. The second line will start the mysql client and let you log in as root, the MySQL user who is in control of the whole server — MySQL users are different from operating system users, so the root user is also different even though the name is the same.
The command will prompt you for a password, which will probably be blank. So you can just press Enter for the password and you’ll be in.
Success here simply shows that you can connect to the MySQL or MariaDB server and that you have correctly added the symbolic links for the mysql client. There’s more to do before you start trying MySQL. So type exit and press Enter to exit the mysql client.
Now that MySQL or MariaDB is installed and running, you need to make some post- installation adjustments, as explained in Post-Installation. Skip ahead to that section.
this, you need WinZip or another utility that you might have installed on your server to uncompress the files. These files need to be copied into the c:\mysql directory. You’ll have to create that directory if it does not already exist on your server. Then, using a plain-text editor (e.g., Notepad) you must create a configuration file that is generally called my.ini in the c:\windows directory. Several examples of this configuration file are provided with the distribution package. Once you have the files in the appropriate place, you can run the setup program. It does provide some assistance, but not as much as the installer.
Before running the installer or the setup program, if MySQL is already installed and
running on your server, and you want to install a newer version, you will first need to shut down the one that’s currently running on your server. For server versions of Windows, it’s generally installed as a service. You can enter something like the following within a
command window to shut down the service and remove it:
mysqld -remove
If MySQL is running on your server, but not as a service, you can enter the following within a command window to shut it down:
msyqladmin -u root -p shutdown
If that returns an error message, you may have to figure out the absolute path for
mysqladmin. Try entering something like the following, adjusting the file path to wherever mysqladmin is located:
"C:\Program Data\MySQL\MySQL Server 5.1\bin\mysqladmin" -u root -p shutdown
After you download the MySQL Installer for Windows from the Windows desktop, double-click on the file’s icon and the Windows Installer program will start. If you’re installing from a ZIP package, look for the file named setup.exe wherever you put the MySQL installation files. Double-click on it to start the installation. From this point, the installation process is pretty much the same for both types of packages.
After you’ve started the installation, once you get past the licensing question and so forth, you will be given a few choices of which type of installation. The Developer choice is the recommended one. However, it will not install the files need for an API, or some other utilities. It will install the MySQL server, libraries, and several MySQL clients on your computer. This is probably the best choice. However, if you’re installing the software on a server and you will be connecting to it from a different computer such as your deskop, you could select “Server only” to install the MySQL server on your server. If you do so, run the installer on your desktop machine and select “Client only” to install only the MySQL clients locally. The MySQL files aren’t very large, though. You could also install the
“Server only” on your server and the Developer package on your desktop. This would allow you to use your desktop as a development environment to learn and test a database before uploading it to your server and making it active. Choose the packages and
combinations that work best for you. Just be sure to have both the MySQL server and the MySQL clients installed somewhere that you can access them.
On the same screen where you choose the setup type, there will be two boxes for file
paths: one where you install the utilities and the other where MySQL stores your data. You can accept the default paths for these or change them, if you want to use a different hard drive or location. The default settings are usually fine. Just make a copy of the paths
somewhere, because you may want to know this information later. You can find it later in the configuration file for MySQL, but while it’s handy now, copy it down: it might save you some time later.
Next, the installer will check whether your computer has the required additional files, besides the MySQL package. Allow it to install whatever files it says you need. For the TAR package, you will have to decide which directory to use and put the files where you want them. A typical choice is C:\Program Data\MySQL\ for the installation path, and C:\Program Data\MySQL\MySQL Server version\data\ for the data path, where the word
version is replaced with the version number.
The last section before the installer finishes is the Configuration screen, where you can set some configuration options. If you want to set options, you can check the box labeled Advanced Configuration, but because you’re still learning about MySQL, you should leave this unchecked and accept the basic default settings for now. You can change the server settings later.
If you’re installing the MySQL server on this machine and not just the clients, you will see a “Start the MySQL Server at System Startup” checkbox. It is a good idea to check that box. In the Configuration section, you can also enter the password for the MySQL root user. Enter a secure password and don’t forget it. You can also add another user. We’ll cover that in Post-Installation. But if you want to make that process easier, you can add a user here for yourself — but I recommend waiting and using MySQL to add users, so you learn that important skill. As for the rest of the choices that the installer gives you, you can probably accept the default settings.
In this book, you will be working and learning from the command line, so you will need to have easy access to the MySQL clients that work from the command line. To invoke the command-line utilities without having to enter the file path to the directory containing them, enter the following from the command line, from any directory:
PATH=%PATH%;C:\Program Data\MySQL\MySQL Server version\bin export PATH
Replace the word version with the version number and make sure to enter the actual path where MySQL is installed. If you changed the location when you installed MySQL, you need to use the path that you named. The line just shown will let you start the client by entering simply mysql and not something like, C:\Program Data\MySQL\MySQL Server
version\bin\mysql each time. For some Windows systems, you may need to change the start of the path to C:\Program Files\. You’ll have to search your system to see where the binary files for MySQL were installed — look for the bin\ subdirectory. Any command windows you may already have open won’t get the new path. So be sure to close them and open a new command window.
Once you’ve finished installing MySQL and you’ve set up the configuration file, the installer will start the MySQL server automatically. If you’ve installed MySQL manually without an installer, enter something like the following from a command window:
mysqld --install net start mysql
Now that MySQL is installed and running, you need to make some post-installation
adjustments, as explained in Post-Installation. So jump ahead to the last couple of pages of
this chapter.