Mysql ��� windows ��� linux

Установка MySQL в Ubuntu 20.04

MySQL — это одна из самых популярных систем управления базами данных, которая применяется почти везде, начиная от различных предприятий и промышленности и заканчивая организацией работы веб-сайтов.

Сейчас существует несколько версий MySQL. Непосредственно MySQL, разрабатываемая компанией Oracle и свободный форк от основного разработчика MySQL — MariaDB. Имя MairaDB программа получила в честь первой дочери программиста, также как и MySQL в честь имени второй. В большинстве дистрибутивов Linux используется MariaDB, в том числе и в Ubuntu. Но в этой статье давайте рассмотрим установку именно MySQL в Ubuntu 20.04.

Установка MySQL 8 в Ubuntu

Программа и все необходимые компоненты есть в официальных репозиториях, поэтому установить её не составит труда. Для установки из официальных репозиториев сначала обновите списки пакетов:

sudo apt update

Затем установите необходимые пакеты:

sudo apt install mysql-server mysql-client

На данный момент в репозиториях Ubuntu 20.04 есть уже версия Mysql 8.20. Вы можете проверить установленную версию такой командой:

Кроме того, желательно проверить, запущенна ли служба MySQL:

sudo systemctl status mysql

Вы должны увидеть зеленую надпись Active, Running и версию программы, которую устанавливали.

Установка MySQL 5.7 в Ubuntu

Если вам нужна версия 5.7, то её в репозиториях нет, но вы можете получить эту версию из репозитория разработчика. Если в системе уже есть более новая версия, её надо полностью удалить:

sudo apt remove —autoremove mysql-server mysql-client

Также удалите каталог с базами данных MySQL они не совместимы со старой версией:

sudo rm -Rf /var/lib/mysql

Для установки репозитория скачайте этот пакет:

sudo wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb

Затем установите его:

sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb

В процессе установки программа попросит выбрать дистрибутив. Если у вас Ubuntu 20.04 или выше, выбирайте версию для Ubuntu 18.04 — bionic:

Затем выберите MySQL Server and Cluster:

После этого останется выбрать нужную версию MySQL, например 5.7:

После этого обновите списки репозиториев и посмотрите какие версии MySQL доступны:

sudo apt update

sudo apt-cache policy mysql-server

Осталось установить установить mysql 5.7 в Ubuntu:

sudo apt install mysql-server=5.7.31-1ubuntu18.04 mysql-community-server=5.7.31-1ubuntu18.04 mysql-client=5.7.31-1ubuntu18.04

В процессе установки программа запросит пароль для root пользователя:

После этого вы снова можете посмотреть версию:

Настройка mysql в Ubuntu

Перед тем как вы сможете полноценно использовать только что установленную базу данных, необходимо выполнить ее первоначальную настройку. Для этого был разработан специальный скрипт, выполните его:

На первом шаге настраивается плагин валидации пароля. Чтобы его включить нажмите Y, или его можно не включать. Затем надо задать сложность пароля, который позволит установить этот плагин. Здесь 0 означает слабый пароль, а 2 — сложный. Когда плагин будет настроен введите пароль root и подтвердите, что хотите использовать именно его:

Введите Y для отключения анонимного доступа к MySQL, затем ещё раз Y чтобы запретить подключаться к базе от имени root удаленно:

Снова Y, чтобы удалить тестовую базу данных. Затем, обновите привилегии для пользователей:

После завершения настройки вы можете подключиться к пользователя root к серверу баз данных из командной строки:

Читайте также:  Windows 10 гаснет экран как отключить

sudo mysql -u root

Здесь нам необходимо создать пользователя, от имени которого мы будем использовать базу данных, а также саму базу данных. Для этого воспользуемся командами SQL. Сначала создаем базу данных:

mysql> CREATE DATABASE testDB;

Далее создадим пользователя:

mysql> CREATE USER ‘my_user’@’localhost’ IDENTIFIED BY ‘password’;

Слова my_user и password нужно заменить на свои имя пользователя и пароль. Дальше нужно дать права пользователю на управление этой базой данных:

mysql> GRANT ALL PRIVILEGES ON testDB.* TO ‘my_user’@’localhost’

Или вы можете дать права только на несколько инструкций:

mysql> GRANT SELECT,UPDATE,DELETE ON testDB.* TO ‘my_user’@’localhost’;

Если какую-либо инструкцию нужно запретить, удалите ее:

mysql> REVOKE UPDATE ON testDB.* FROM ‘my_user’@’localhost’;

После завершения работы с правами нужно их обновить:

mysql> FLUSH PRIVILEGES;

Чтобы убедиться что нет никого лишнего, вы можете вывести список пользователей:

mysql> SELECT user,host FROM mysql.user;

Также вы можете посмотреть полномочия для нужного пользователя:

mysql> SHOW GRANTS FOR ‘my_user’@’localhost’;

Теперь установка MySQL Ubuntu 20.04 полностью завершена и вы можете использовать эту базу данных для решения своих задач.

Удаление MySQL в Ubuntu

Чтобы удалить mysql Ubuntu 20.04 понадобиться немного больше команд чем для удаления простого пакета. После удаления основных пакетов в системе остается еще много файлов. Мы рассмотрим как удалить все.

Сначала остановите сервисы:

sudo systemctl stop mysql
sudo killall -KILL mysql mysqld_safe mysqld

Удалите основные пакеты и их зависимости:

sudo apt -y purge mysql-server mysql-client
sudo apt -y autoremove —purge
sudo apt autoclean

Удалите пользователя mysql и остатки программы в системе:

deluser —remove-home mysql
sudo delgroup mysql
rm -rf /etc/apparmor.d/abstractions/mysql /etc/apparmor.d/cache/usr.sbin.mysqld /etc/mysql /var/lib/mysql /var/log/mysql* /var/log/upstart/mysql.log* /var/run/mysqld
updatedb

Удалите все логи подключений к mysql из терминала:

sudo find / -name .mysql_history -delete

Теперь ваша система полностью очищена от MySQL.

Выводы

В этой статье мы рассмотрели как выполняется установка MySQL в Ubuntu 20.04. Как видите, это не очень трудно, хотя и требует некоторых знаний и немного времени на то, чтобы со всем разобраться. Надеюсь, эта информация была для вас полезной.

Источник

Mysql ��� windows ��� linux

Linux supports a number of different solutions for installing MySQL. We recommend that you use one of the distributions from Oracle, for which several methods for installation are available:

Table 2.8 Linux Installation Methods and Information

Type Setup Method Additional Information
Apt Enable the MySQL Apt repository Documentation
Yum Enable the MySQL Yum repository Documentation
Zypper Enable the MySQL SLES repository Documentation
RPM Download a specific package Documentation
DEB Download a specific package Documentation
Generic Download a generic package Documentation
Source Compile from source Documentation
Docker Use the Oracle Container Registry. You can also use Docker Hub for MySQL Community Edition and My Oracle Support for MySQL Enterprise Edition. Documentation
Oracle Unbreakable Linux Network Use ULN channels Documentation

As an alternative, you can use the package manager on your system to automatically download and install MySQL with packages from the native software repositories of your Linux distribution. These native packages are often several versions behind the currently available release. You are also normally unable to install development milestone releases (DMRs), since these are not usually made available in the native repositories. For more information on using the native package installers, see Section 2.5.7, “Installing MySQL on Linux from the Native Software Repositories”.

Источник

Mysql ��� windows ��� linux

MySQL 8.0 Server requires the Microsoft Visual C++ 2019 Redistributable Package to run on Windows platforms. Users should make sure the package has been installed on the system before installing the server. The package is available at the Microsoft Download Center. Additionally, MySQL debug binaries require Visual Studio 2019 to be installed.

MySQL is available for Microsoft Windows 64-bit operating systems only. For supported Windows platform information, see https://www.mysql.com/support/supportedplatforms/database.html.

There are different methods to install MySQL on Microsoft Windows.

MySQL Installer Method

The simplest and recommended method is to download MySQL Installer (for Windows) and let it install and configure a specific version of MySQL Server as follows:

Download MySQL Installer from https://dev.mysql.com/downloads/installer/ and execute it.

Unlike the standard MySQL Installer, the smaller web-community version does not bundle any MySQL applications, but downloads only the MySQL products you choose to install.

Determine the setup type to use for the initial installation of MySQL products. For example:

Developer Default : Provides a setup type that includes the selected version of MySQL Server and other MySQL tools related to MySQL development, such as MySQL Workbench.

Server Only : Provides a setup for the selected version of MySQL Server without other products.

Custom : Enables you to select any version of MySQL Server and other MySQL products.

Install the server instance (and products) and then begin the server configuration by following the onscreen instructions. For more information about each individual step, see Section 2.3.3.3.1, “MySQL Server Configuration with MySQL Installer”.

MySQL is now installed. If you configured MySQL as a service, then Windows automatically starts the MySQL server every time you restart the system. Also, this process installs the MySQL Installer application on the local host, which you can use later to upgrade or reconfigure MySQL server.

If you installed MySQL Workbench on your system, consider using it to check your new MySQL server connection. By default, the program automatically start after installing MySQL.

Additional Installation Information

It is possible to run MySQL as a standard application or as a Windows service. By using a service, you can monitor and control the operation of the server through the standard Windows service management tools. For more information, see Section 2.3.4.8, “Starting MySQL as a Windows Service”.

To accommodate the RESTART statement, the MySQL server forks when run as a service or standalone, to enable a monitor process to supervise the server process. In this case, there are two mysqld processes. If RESTART capability is not required, the server can be started with the —no-monitor option. See Section 13.7.8.8, “RESTART Statement”.

Generally, you should install MySQL on Windows using an account that has administrator rights. Otherwise, you may encounter problems with certain operations such as editing the PATH environment variable or accessing the Service Control Manager . When installed, MySQL does not need to be executed using a user with Administrator privileges.

For a list of limitations on the use of MySQL on the Windows platform, see Section 2.3.7, “Windows Platform Restrictions”.

In addition to the MySQL Server package, you may need or want additional components to use MySQL with your application or development environment. These include, but are not limited to:

To connect to the MySQL server using ODBC, you must have a Connector/ODBC driver. For more information, including installation and configuration instructions, see MySQL Connector/ODBC Developer Guide.

MySQL Installer installs and configures Connector/ODBC for you.

To use MySQL server with .NET applications, you must have the Connector/NET driver. For more information, including installation and configuration instructions, see MySQL Connector/NET Developer Guide.

MySQL Installer installs and configures MySQL Connector/NET for you.

MySQL for Windows is available in several distribution formats, detailed here. Generally speaking, you should use MySQL Installer. It contains more features and MySQL products than the older MSI, is simpler to use than the compressed file, and you need no additional tools to get MySQL up and running. MySQL Installer automatically installs MySQL Server and additional MySQL products, creates an options file, starts the server, and enables you to create default user accounts. For more information on choosing a package, see Section 2.3.2, “Choosing an Installation Package”.

A MySQL Installer distribution includes MySQL Server and additional MySQL products including MySQL Workbench, and MySQL for Visual Studio. MySQL Installer can also be used to upgrade these products in the future (see https://dev.mysql.com/doc/mysql-compat-matrix/en/).

For instructions on installing MySQL using MySQL Installer, see Section 2.3.3, “MySQL Installer for Windows”.

The standard binary distribution (packaged as a compressed file) contains all of the necessary files that you unpack into your chosen location. This package contains all of the files in the full Windows MSI Installer package, but does not include an installation program.

The source distribution format contains all the code and support files for building the executables using the Visual Studio compiler system.

For instructions on building MySQL from source on Windows, see Section 2.9, “Installing MySQL from Source”.

MySQL on Windows Considerations

Large Table Support

If you need tables with a size larger than 4GB, install MySQL on an NTFS or newer file system. Do not forget to use MAX_ROWS and AVG_ROW_LENGTH when you create tables. See Section 13.1.20, “CREATE TABLE Statement”.

MySQL and Virus Checking Software

Virus-scanning software such as Norton/Symantec Anti-Virus on directories containing MySQL data and temporary tables can cause issues, both in terms of the performance of MySQL and the virus-scanning software misidentifying the contents of the files as containing spam. This is due to the fingerprinting mechanism used by the virus-scanning software, and the way in which MySQL rapidly updates different files, which may be identified as a potential security risk.

After installing MySQL Server, it is recommended that you disable virus scanning on the main directory ( datadir ) used to store your MySQL table data. There is usually a system built into the virus-scanning software to enable specific directories to be ignored.

Источник

Читайте также:  Как восстановить запуск windows 10 после неудачного обновления
Оцените статью