Предварительно добавляем следующие строки в /etc/make.conf
DEFAULT_MYSQL_VER=55
PORTSDIR?= /usr/ports
.if ${.CURDIR} == ${PORTSDIR}/databases/mysql${DEFAULT_MYSQL_VER}-server
WITH_CHARSET=utf8
WITH_COLLATION=utf8_bin
WITH_XCHARSET=all
.endif
.if ${.CURDIR} == ${PORTSDIR}/databases/mysql${DEFAULT_MYSQL_VER}-client
WITH_CHARSET=utf8
WITH_COLLATION=utf8_bin
.endif
PORTSDIR?= /usr/ports
.if ${.CURDIR} == ${PORTSDIR}/databases/mysql${DEFAULT_MYSQL_VER}-server
WITH_CHARSET=utf8
WITH_COLLATION=utf8_bin
WITH_XCHARSET=all
.endif
.if ${.CURDIR} == ${PORTSDIR}/databases/mysql${DEFAULT_MYSQL_VER}-client
WITH_CHARSET=utf8
WITH_COLLATION=utf8_bin
.endif
переходим в ports и компилируем сервер
# cd /usr/ports/databases/mysql55-server/
# make install clean
# rehash
# make install clean
# rehash
Производим первоначальную настройку MySQL сервера. Настраиваем запуск MySQL вместе с системой
# echo 'mysql_enable="YES"' >> /etc/rc.conf
Запускаем MySQL
# /usr/local/etc/rc.d/mysql-server start
Starting mysql.
Starting mysql.
А теперь воспользуемся скриптом для настройки безопасности MySQL сервера
# /usr/local/bin/mysql_secure_installation
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]Y
... 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]Y
... 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]Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... 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!
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]Y
... 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]Y
... 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]Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... 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!
Что делает скрипт mysql_secure_installation ? :
Как видно из названия самого скрипта он предназначен для повышения безопасности MySQL сервера. С помощью этого скрипта мы выполнили следующие действия:
* задали пароль для супер пользователя root (с системным root он не имеет ничего общего, это абсолютно два разных пользователя), так как по умолчанию для него не установлен пароль;
* удалили анонимного пользователя, который создается только для тестовых целей;
* запретили пользователю root входить удаленно. Теперь он сможет заходить только с localhost;
* удалили тестовую БД test и доступ к ней;
можно не использовать скрипт, но как минимум сменить пароль на root необходимо:
# mysql
- UPDATE mysql.user SET password=PASSWORD("my-new-password") WHERE User='root';
- FLUSH PRIVILEGES;
и на последок пишем/правим конфиг - my.cnf, у меня в начале он вот такой:
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
init-connect="SET NAMES utf8"
[mysqldump]
default-character-set=utf8
[client]
default-character-set=utf8
character-set-server=utf8
collation-server=utf8_general_ci
init-connect="SET NAMES utf8"
[mysqldump]
default-character-set=utf8
[client]
default-character-set=utf8
DEFAULT_MYSQL_VER=55
PORTSDIR?= /usr/ports
DEFAULT_VERSIONS=mysql=5.5 apache=2.4
mysql_args="--bind-address=127.0.0.1"
возможно у Вас отключен javascript, если включен - просто обновите страницу