Installing on OS X

Apple's OS X (“OS Ten”) is a combination of a graphical front-end with a core operating system based on BSD. The ease-of-use of a Macintosh front-end is welded to a reliable Unix-based core.

The BSD core means that MySQL, PHP, Apache, and other applications that run on Linux, can normally be run on OS X.

You will need to have Administrator privilege to perform this installation. On OS X, this doesn't mean becoming root; it just requires that you log on as a user with Administrator privilege.

Download the binary file called something like mysql-4.0.1-alpha-apple-darwin5.1-powerpc.tar.gz (the filename depends on the MySQL version) from the MySQL Web site. When the download is finished, double-click the icon, and it should unpack into a folder called mysql-4.0.1-alpha-apple-darwin5. (The folder's name may be slightly different on your system, so in the next instructions you may need to modify them to suit your system.)

Then move the folder to /usr/local directory using the following commands. Start up Terminal and type this:

$ cd Desktop
$ sudo mv mysql-4.0.1-alpha-apple-darwin5 /usr/local
					

This first changes to the Desktop directory (where you downloaded the compressed file to) and moves the new folder to the /usr/local directory. You need sudo before mv because superuser permissions are required to place anything in the /usr/local directory, and you will be asked to enter your OS X Administrator password (not the root password).

You'll need to create the MySQL user, so start up System Preferences, select Users, and click on the New User button. Specify Name as MySQL User, specify short name mysql, and create a password of your choice.

Then change to the new directory, run the script to initialize the data directory, change file ownerships to mysql, and start the server:

$ cd /usr/local/mysql-4*
$ sudo ./scripts/mysql_install_db
$ sudo chown -R mysql /usr/local/mysql-4*/*
$ sudo ./bin/mysqld_safe --user=mysql &
					

To verify that things have gone well, make sure that MySQL is running as it should be. Still in Terminal, start the mysql console by typing the following:

$ /usr/local/mysql-4*/bin/mysql -u root
					

This brings up the mysql monitor, logging in as the MySQL root user as specified after the -u. You can experiment further if you want (as we'll do soon), or simply type

mysql> exit
					

to end the session.

After you complete the installation, set the root password. This can be done as follows:

$ /usr/local/mysql-4*/bin/mysqladmin -u root password newpass
					

Subsequent password changes will need you to provide the existing one by adding a -p; so for future changes, you would use

$ /usr/local/mysql-4*/bin/mysqladmin -u root -p password newpass
					

After a password has been set, you will also need the -p option when using the mysql program, as well as the -u option to specify the MySQL user to log in as. (We'll go into starting and using mysql more thoroughly in Day 6, “Manipulating a Database.”) To start mysql with a username and password specified, you would use

$ /usr/local/mysql-4*/bin/mysql -u root -p
					

This completes a basic installation for MySQL on OS X. It is possible to make the client scripts more convenient to use, without typing the full path (as we did in the Linux installation), and you can also have the MySQL server start up automatically when you start OS X. We omitted these steps from this lesson to keep things simple. You will find more notes on these things on the accompanying Web site, or at http://www.entropy.ch/software/macosx/mysql/, which has a good deal of information and downloadable packages.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.135.36