2.4.1 General Notes on Installing MySQL on OS X
You should keep the following issues and notes in mind:
- As of MySQL server 5.5.45, the DMG bundles a launchd daemon instead of the deprecated startup item. Startup items do not function as of OS X 10.10 (Yosemite), so using launchd is preferred. The available MySQL preference pane under OS X System Preferences was also updated to use launchd.
- You may need (or want) to create a specific
mysqluser to own the MySQL directory and data. You can do this through the Directory Utility, and the
mysqluser should already exist. For use in single user mode, an entry for
_mysql(note the underscore prefix) should already exist within the system
- Because the MySQL package installer installs the MySQL contents into a version and platform specific directory, you can use this to upgrade and migrate your database between versions. You will need to either copy the
datadirectory from the old version to the new version, or alternatively specify an alternative
datadirvalue to set location of the data directory. By default, the MySQL directories are installed under
- You might want to add aliases to your shell’s resource file to make it easier to access commonly used programs such as mysql and mysqladmin from the command line. The syntax for bash is:
alias mysql=/usr/local/mysql/bin/mysql alias mysqladmin=/usr/local/mysql/bin/mysqladmin
For tcsh, use:
alias mysql /usr/local/mysql/bin/mysql alias mysqladmin /usr/local/mysql/bin/mysqladmin
Even better, add
PATHenvironment variable. You can do this by modifying the appropriate startup file for your shell. For more information, see Section 4.2.1, “Invoking MySQL Programs”.
Verifying MySQL Installation
After MySQL, has been successfully installed, the base tables have been initialized and the server has been started: you can verify that everything is working as it should be via some simple tests.
Use the mysqladmin Utility to Obtain Server Status
Use mysqladmin binary to check the server version. This binary would be available in /usr/bin on linux and in C:\mysql\bin on windows.
[root@host]# mysqladmin --version
It will produce the following result on Linux. It may vary depending on your installation −
mysqladmin Ver 8.23 Distrib 5.0.9-0, for redhat-linux-gnu on i386
If you do not get such a message, then there may be some problem in your installation and you would need some help to fix it.
Execute simple SQL commands using the MySQL Client
You can connect to your MySQL server through the MySQL client and by using the mysql command. At this moment, you do not need to give any password as by default it will be set as blank.
You can just use following command −
It should be rewarded with a mysql> prompt. Now, you are connected to the MySQL server and you can execute all the SQL commands at the mysql> prompt as follows −
mysql> SHOW DATABASES; +----------+ | Database | +----------+ | mysql | | test | +----------+ 2 rows in set (0.13 sec)
MySQL ships with a blank password for the root MySQL user. As soon as you have successfully installed the database and the client, you need to set a root password as given in the following code block −
[root@host]# mysqladmin -u root password "new_password";
Now to make a connection to your MySQL server, you would have to use the following command −
[root@host]# mysql -u root -p Enter password:*******
UNIX users will also want to put your MySQL directory in your PATH, so you won’t have to keep typing out the full path everytime you want to use the command-line client.
For bash, it would be something like −
export PATH = $PATH:/usr/bin:/usr/sbin
Running MySQL at Boot Time
If you want to run the MySQL server at boot time, then make sure you have the following entry in the /etc/rc.local file.
Also,you should have the mysqld binary in the /etc/init.d/ directory.
Cited from https://dev.mysql.com/doc/refman/5.5/en/osx-installation-notes.html