Skip to main content

MySQL macport install on Mac OS X Tiger

I have installed mysql5 macport on the MacBookPro laptop running OS X Tiger 10.4.

There are a few steps that needs to be done once the port is installed. These steps are not documented (see Ticket #12694 on macports.org). So, after reading a few blogs and analyzing mysql startup error messages, I figured out what needs to be done in order to get it running. That info might be useful to others, so I’ve decided to publish the solution here.

First of all, we need to create the initial database database

$ sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql

Here is the output of the command:


$ sudo ./mysql_install_db --user=mysql

Installing MySQL system tables...
071118 0:06:29 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive
OK
Filling help tables...
071118 0:06:29 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql5/bin/mysqladmin -u root -h my-computer.local password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com


Next, I’ve tried to start the database and got this error message:

$ sudo /opt/local/lib/mysql5/bin/mysqld_safe
mkdir: /opt/local/var/run: No such file or directory
chown: /opt/local/var/run/mysql5: No such file or directory
chmod: /opt/local/var/run/mysql5: No such file or directory
Starting mysqld daemon with databases from /opt/local/var/db/mysql5
STOPPING server from pid file /opt/local/var/db/mysql5/mykola-dzyubas-computer-2.local.pid
071118 00:27:12 mysqld ended

I’ve created /opt/local/var/run and /opt/local/var/run/mysql5 folders:

sudo mkdir /opt/local/var/run
sudo chmod g+w /opt/local/var/run
sudo mkdir /opt/local/var/run/mysql5
sudo chown mysql /opt/local/var/run/mysql5

Once it is done, the mysql server has started successfully

$ sudo /opt/local/lib/mysql5/bin/mysqld_safe &
Starting mysqld daemon with databases from /opt/local/var/db/mysql5

Here is a quick check that the database server is up:

$ mysqladmin5 -u root -p ping
Enter password:
mysqld is alive

In case you don't have mysql binary files in your path, please edit ~/.profile and add /opt/local/bin to the path:

# Setting the path for MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH

By default all scripts refer to mysql command, however the installation package creates mysql5. To fix that, create mysql symbolic link that points to mysql5.

$ cd /opt/local/bin
$ ln -s mysql5 mysql

To improve security of the mysql server configuration, please run mysql_secure_installation5 script and configure mysql password for root, network access, etc:




$ cd /opt/local/bin
$ ./mysql_secure_installation5

mykola-dzyubas-computer-2:/opt/local/bin mykola$ ./mysql_secure_installation5




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]
... Success!

By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n
... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
... Success!

Cleaning up...



All done! If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Comments

Tai Viinikka said…
Solid, valuable, and complete. Thank you very much!
Mike said…
Here is a bug that you should know about.

I tried to run mysql_secure_installation5 but kept getting an error:

/opt/local/bin/mysql_secure_installation5: line 42: mysql: command not found
... Failed!

The issue was that 'mysql' is the command on line 42. You need to change this to mysql5 and the script runs correctly. Hope this helps.
Anonymous said…
I was getting the line 42 error as well - mysql not found. In my case I just added the mysql bin directory to the path and it worked.

E.G. PATH="$PATH:/usr/local/mysql/bin"

I did the above under linux, but I assume Mac OS would be the same.

Popular posts from this blog

Building a Flex project with Ant

Here is a quick sample on how to build a simple Flex "hello world" project with Ant. The "hello world" project contains a src folder with one Flex application file and an Ant build.xml file: ./project_home/ ./src/ app.mxml build.xml The app.mxml is the main module of the project. It simply has a label with a "Hello World!" text: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Label text="Hello World!"/> </mx:Application> Here is the build.xml source: <?xml version="1.0"?> <project name="fx_practice7" default="all"> <!-- Init the build process --> <target name="init" unless="initialized"> <!-- Name of project and version --> <property name="FLEX_HOME" location="/Users/mykola/java/flex"/>

cucumber-jvm and Android Studio

During this Winter holidays, I've been exploring a Behavior Driven Development and experimented with a couple of testing frameworks: Calabash and cucumber-jvm . In this post, I would like to describe setting up cucumber-jvm for Android Studio projects. I've extended cucumber-jvm examples with a version for Android Studio. Here is a copy in my github branch: https://github.com/mdzyuba/cucumber-jvm/tree/add_android_studio_example/examples/android/android-studio/Cukeulator . In addition to the example code, here is some details on how it was created. Dependencies The cucumber-jvm requires several libraries to be added to a project:  https://github.com/cucumber/cucumber-jvm/tree/master/android I've found it's easier to add those dependencies with the Android Studio project setup dialog because it takes care of the jar versions for you. File > Project Structure > Modules > app > Dependencies > + > Library dependency   > type "cuc

Using FlexUnit for Stress Testing

I saw quite a few questions in the forums on how to stress test a Flex application. I thought about it and came up with an idea that I want to share here. I think FlexUnit can be used for stress testing. It is not that difficult. I simply add multiple test runners for each client application and run all of them asynchronously. Here is the example of the FlexUnit runner: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" xmlns:flexunit="flexunit.flexui.*" creationComplete="onCreationComplete()"> <mx:Script> <![CDATA[ import flexunit.framework.TestSuite; import test.TemperatureConverterTest; import test.ArrayUtilTest; import mx.collections.ArrayCollection; import flexunit.flexui.TestRunnerBase; [Bindable] public var testClients:ArrayCollection; public var NUMBER_OF_TESTS:int = 100; private function onCreationComple