Install MySQL
MySQL Server & Client Installation
# portinstall databases/mysql51-server
# rehash
Add the following line to /etc/rc.conf to enable mysql on boot:
# echo mysql_enable="YES" >> /etc/rc.conf
You can start the MySQL daemon with:
# cd /usr/local ; /usr/local/bin/mysqld_safe &
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER!
***NOTE*** The password CANNOT contain the following characters: !'@
if I wanted my MYSQL root password to be new_password , I would use the following commands.
# mysql -u root mysql
it is now going to give me a new prompt. At that prompt, I type (or paste)
UPDATE user SET Password=PASSWORD('new_password') WHERE user='root';
then I enter
FLUSH PRIVILEGES;
and then
quit
and I am back at the # prompt.
That will allow access from the localhost. However, to allow root access from outside the localhost, we must 'grant' that access.
First, logon to mysql using # mysql -u root mysql -pnew_password or just don't 'quit' from above and add the following:
GRANT ALL PRIVILEGES ON *.* TO root@"%" identified by 'new_password' with grant option;
hit enter
FLUSH PRIVILEGES;
hit enter
quit
and you are back at the # prompt.
Now, lets test this all out to make sure it works.
reboot the system with the following command
# shutdown -r now
when the system comes back up, log in as yourself. The $ prompt means you are NOT a super user (su). Become a super user by issuing the su command as follows.
$ su - root
now type
# ps -ax|grep mysql
You should see something similar to this
34620 p0- I 0:00.01 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --datadir=/var
34640 p0- S 5:35.68 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var/
40310 p0 S+ 0:00.00 grep mysql
if all you see is the last entry ( grep mysql ) and no other jobs listed, mysql is not running and you need to figure it out before continuing to the next article.