Последние новости:

Поиск по сайту:

Для машин естественные языки не естественны. (Алан.Дж.Перлис)

Как установить MySQL на Linux

04.11.2016
Как установить MySQL на Linux

Большинство дистрибутивов Linux поставляется с MySQL.Если вы хотите использовать MySQL, моя рекомендация состоит в том, чтобы вы скачали последнюю версию MySQL и установили её самостоятельно. Позже вы можете обновить её до последней версии, когда она станет доступной. В этой статье я расскажу, как установить последнюю версию свободного MySQL на платформе Linux.

1. Загрузите последнюю стабильную версию MySQL

Скачать MySql из mysql.com. Пожалуйста, загрузите выпуск MySQL для соответствующей платформы Linux. Я скачал «Red Hat Enterprise Linux 5 RPM (x86)«. Убедитесь в том, чтобы загрузить MySQL сервер, клиент и «Headers and libraries» на странице загрузки.

  • MySQL-client-community-5.1.25-0.rhel5.i386.rpm
  • MySQL-server-community-5.1.25-0.rhel5.i386.rpm
  • MySQL-devel-community-5.1.25-0.rhel5.i386.rpm

2. Удалите существующий MySQL по умолчанию, поставляемой вместе с дистрибутивом Linux

Не выполняйте это на системе, в которой база данных MySQL необходима некоторым приложениям.

[local-host]# rpm -qa | grep -i mysql
mysql-5.0.22-2.1.0.1
mysqlclient10-3.23.58-4.RHEL4.1

[local-host]# rpm -e mysql --nodeps
warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave
[local-host]# rpm -e mysqlclient10

 

3. Установите загруженный пакет MySQL

Установите пакеты клиент  и сервер MySQL, как показано ниже.

[local-host]# rpm -ivh MySQL-server-community-5.1.25-0.rhel5.i386.rpm MySQL-client-community-5.1.25-0.rhel5.i386.rpm
Preparing...                ########################################### [100%]
1:MySQL-client-community ########################################### [ 50%]
2:MySQL-server-community ########################################### [100%]


Это также покажет следующий вывод и запустить демон MySQL автоматически.

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h medica2 password 'new-password'

Alternatively you can run:
/usr/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.
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/

Starting MySQL.[  OK  ]
Giving mysqld 2 seconds to start

 

Установите «Headers and libraries«, который являются частью пакетов MySQL.

[local-host]# rpm -ivh MySQL-devel-community-5.1.25-0.rhel5.i386.rpm
Preparing...                ########################################### [100%]
1:MySQL-devel-community  ########################################### [100%]

 

Примечание: Когда я делал компиляцию PHP с опцией MySQL из источника в системе Linux, она потерпела неудачу с ошибкой. Установка пакета MySQL-devel-community устранена эта проблема была с установка PHP из исходных текстов.

configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore!

 

4. Выполните послеустановочную действий по обеспечению безопасности на MySQL.

Как минимум вы должны установить пароль для пользователя root, как показано ниже:

[local-user]# /usr/bin/mysqladmin -u root password 'My2Secure$Password'

 

Наилучшим вариантом является, запустить сценарий mysql_secure_installation, который будет заботиться о безопасности, связанных элементов на MySQL, как показано ниже. На высоком уровне установим следующие пункты:

  • Изменение пароля
  • Удалить анонимного пользователя
  • Запрещает вход root с удаленных машин
  • Удалить тестовую базу данных образца по умолчанию
[local-host]# /usr/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.
You already have a root password set, so you can safely answer 'n'.
Change the 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!

 

5. Проверьте правильность установки MySQL:

Вы можете проверить MySQL, какая установлена версия MySQL, выполнив -V, как показано ниже:

[local-host]# mysql -V
mysql  Ver 14.14 Distrib 5.1.25-rc, for redhat-linux-gnu (i686) using readline 5.1

 

Подключение к базе данных MySQL с помощью пользователя root и убедитесь, что соединение успешно.

[local-host]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.1.25-rc-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

 

Соблюдайте следующие шаги, чтобы остановить и запустить MySQL

[local-host]# service mysql status
MySQL running (12588)                                      [  OK  ]
[local-host]# service mysql stop
Shutting down MySQL.                                       [  OK  ]
[local-host]# service mysql start
Starting MySQL.                                            [  OK  ]

 

Как установить MySQL на Linux

Если вы нашли ошибку, пожалуйста, выделите фрагмент текста и нажмите Ctrl+Enter.

1 Звезда2 Звезды3 Звезды4 Звезды5 Звезд (1 оценок, среднее: 5,00 из 5)
Загрузка...
Поделиться в соц. сетях:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

**ссылки nofollow

0 комментариев
Межтекстовые Отзывы
Посмотреть все комментарии

Читайте также

Статьи партнеров:

0
Оставьте комментарий! Напишите, что думаете по поводу статьи.x

Сообщить об опечатке

Текст, который будет отправлен нашим редакторам:

Заполните форму и наш менеджер перезвонит Вам в самое ближайшее время!

badge
Обратный звонок 1
Отправить

Спасибо! Ваша заявка принята

close

Спасибо! Ваша заявка принята

close