Installing MySQL 5.0 in FreeBSD 7.1
FreeBSD & BSD, Tecnología February 1st, 2009Quick guide to help you install the MySQL database server into your FreeBSD machine.
first check that your system does not have the server already installed:
[raistlin@havoc /usr/home/raistlin]$ pkg_info | grep mysql
mysql-client-5.0.75 Multithreaded SQL database (client)
Usually you will have the client installed, it’s used by other packages.
If you have another version of the client installed (4.x, 5.5 or 6.x) I suggest you to install that same server, these steps should do anyway.
Next, if we don’t have the server already installed we can install it in two different ways:
- Using the packages:
# pkg_add -r mysql50-server
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7-stable/Latest/mysql50-server.tbz... Done.
.
.
.
- Using the ports:
#cd /usr/ports/databases/mysql50-server
#make install clean
The second option lets you fine tune some parameters of the build process, remeber to write them with the options chosen in /etc/make.conf (This way when performing an upgrade you won’t asked for the build parameters).
Once you jave the server installed run:
# mysql_install_db --user=mysql
Installing MySQL system tables...
090131 22:46:22 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
090131 22:46:22 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
OK
.
.
.
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/bin/mysqladmin -u root password 'new-password'
/usr/local/bin/mysqladmin -u root -h havoc.local password 'new-password'
Alternatively you can run:
/usr/local/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local ; /usr/local/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 /usr/local/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
Now change some permissions and try to run the server:
# chown -R mysql /var/db/mysql/
# chgrp -R mysql /var/db/mysql/
/usr/local/bin/mysqld_safe -user=mysql &
[1] 1380
# Starting mysqld daemon with databases from /var/db/mysql
Then, as told by the install db script we’ll set the mysql root password, note that the mysql root user is not related with the root user in the system, I’ve heard this assumption before.
#/usr/local/bin/mysqladmin -u root password 'secret'
#/usr/local/bin/mysqladmin -u root -h computer.local password 'secret'
The second time we’ll be asked for the password we just set in the first command.
Now we have a running MySQL server, you can configure how it behaves modifying the my.cnf file and configuring the system to start the server at boot time.
Start at boot time:
Add mysql_enable=”YES” to /etc/rc.conf
Set a configuration:
The installation left example configuration files in /usr/local/examples/mysql
Copy of of these: followinf files to /var/db/mysql/my.cnf and modify it to suit your needs:
(This step is optional).
my-huge.cnf
my-large.cnf
my-medim.cnf
my-small.cnf
my-innodb-heavy-4G.cnf
Now you have a running MySQL server running and configured.
February 10th, 2009 at 03:41
hi,
i installed i via
#cd /usr/ports/databases/mysql50-server
#make install clean
i can’t install properly mysql tables (# mysql_install_db –user=mysql) beacause
my hostname is ‘localhost’
so i used this tip
http://howflow.com/tricks/solution_for_error_1062_duplicate_entry_localhost_for_key_1
put then i cannot connect to mysql, mysqladmin doesn’t want me to set up for a root password.
no users in the user table
any help ?
February 10th, 2009 at 16:27
Hi.
Have you tried desinstalling the MySQL Server (make deinstall) and then.
Set the hostname to something else (better if you set this name in rc.conf, so you’ll have this set for subsecuents reboots).
Reinstall the server again and follow the usual process.
I know there’s nothing new here but now with the if you gave and the post I don’t really know why you were left with no users in the database.
Let me know how it goes and maybe (with more time) I can see what actually happens.
Best Regards.
March 4th, 2009 at 03:48
Hi,
I’ve just installed mysql-server-5.0.77 on FreeBSD 6.3-RELEASE and the mysql_secure_installation script doesn’t seem to be included:
# pkg_info -L mysql-server-5.0.77 | grep \/usr\/local\/bin\/mysql_
/usr/local/bin/mysql_install_db
/usr/local/bin/mysql_tzinfo_to_sql
/usr/local/bin/mysql_upgrade_shell
/usr/local/bin/mysql_waitpid
Any idea why?
Cheers,
Rob