- Как в Windows модифицировать PATH для быстрого вызова exe-шников MySQL?
- Installing MySQL (Windows, Linux and Mac)
- Installing MySQL on Windows #
- Adding MySQL to PATH Environment Variable in Windows #
- Install MySQL in Debian/Ubuntu/Mint #
- Testing the Installation #
- Installing MySQL on Mac OS #
- Adding MySQL to Path Environment Variable in Mac OS #
- Getting MySQL path in command prompt
- 13 Answers 13
Как в Windows модифицировать PATH для быстрого вызова exe-шников MySQL?
Стоит сервер MySQL, в папке C:\Program Files\MySQL\MySQL Server 5.6\bin находятся его утилиты. Что и где надо прописать, чтобы в cmd.exe я мог просто написать имя любого из exe в вышеуказанной папке и чтоб консоль обращалась к файлам именно в ней, а не в текущей?
Например чтобы входить в консоль MySQL через Win+R -> cmd -> mysql -uroot -ppassword
Таки добавил в PATH. SET отображает:
mysql=C:\Program Files\MySQL\MySQL Server 5.6\bin\mysql.exe
Но всё равно командная строка пишет:
C:\Users\Администратор>mysql
«mysql» не является внутренней или внешней
командой, исполняемой программой или пакетным файлом.
- Вопрос задан более трёх лет назад
- 5332 просмотра
Свойства компьютера
Advanced
Environment variables
Ищете в системных переменных PATH и добавляете туда нужные пути, разделяя их точкой с запятой.
Порядок важен для двух моментов — и скорость поиска незначительно повысится, и если в двух разных каталогах будет один и тот же exe файл, выполнится тот, который стоит в PATH раньше.
Посторонним В.: Вывод, задание и удаление переменных среды cmd.exe.
переменная Имя переменной среды.
строка Строка символов, присваиваемая указанной переменной.
Введите SET без параметров для вывода текущих переменных среды.
Изменение команды SET при включении расширенной обработки команд:
Если при вызове указать только имя переменной без знака равенства и значения,
команда SET выведет значения всех переменных, имя которых начинается
с указанной строки. Например:
Эта команда выведет значения всех переменных, имена которых начинаются с ‘P’.
Если имя переменной не найдено в текущей среде, при возврате команда SET
установит значение ошибки ERRORLEVEL 1.
Команда SET не допускает использование знака равенства в имени
Installing MySQL (Windows, Linux and Mac)
Last updated on July 27, 2020
MySQL is one of the most used Relational databases on the Web and in this lesson, we will learn how to install it.
This post specifically covers how to install MySQL on Windows, Linux and Mac OS.
Installing MySQL on Windows #
To download MySQL for Windows navigate to https://dev.mysql.com/downloads/windows/installer/. Scroll down a little and you will be displayed download links like this:
The first one is a web installer and the second one is an offline installer. Select whichever you like and hit the Download button.
After the download finishes double-click to start the installer.
Step 1: Accepts Licence Agreement.
Step 2: Select Setup Type.
The default set up installs many additional packages like MySQL workbench, Connectors, plugins, documentation, samples databases and so on. Installing all these packages will take some time and additional space. And the worst part is you won’t even use half of these packages. That’s why it is better to go with the Custom Installation and only install the packages you need. Don’t worry you can always install these packages later by running installer again.
Step 3: Select Product and Features.
In this case, we are only interested in installing MySQL server. Select architecture ( x86 or x64 ) depending upon your OS and click Next.
Step 4: Check Requirements.
In this screen, the installer will download the missing dependencies. You will see this screen only when your system has missing dependencies. Click the «Execute» button to start the process. As you can see, on this system, installers need Microsoft Visual C++ Redistributable Package before it can proceed. Click the Next button and installer will prompt you to install the necessary package.
Once you have installed all the dependencies you will see a green check mark before the product name.
Step 5: Installation.
This screen shows the list of products that will be installed. The list only contains MySQL Server because that’s what we are installing here. To start the installation process click the Execute button. After successful installation, you will get the following screen.
Click Next to proceed.
Step 6: Product Configuration.
In this part, the installer will configure MySQL Server. Default options are fine, so just click Next on the next on the several screens. After that, you will be prompted for username and password. Set username and password of your choice. You will use this to login into the MySQL server.
You have made through the hard part of the installation phase. In the next several screens accept the default by clicking Next. Finally, close the installer by clicking the Finish button.
Adding MySQL to PATH Environment Variable in Windows #
MySQL Installer by default doesn’t add the mysql.exe to the PATH environment variable. As a result, every time we want to execute mysql.exe we have to specify the full path to it. The mysql.exe resides in the MySQL\MySQL Server 5.7\bin directory. But the path to MySQL directory depends upon the architecture of the application. If you have installed x64 version then it should be in C:\Program Files\ . Otherwise, it should be in C:\Program Files (x86) . On this system, MySQL is installation is in C:\Program Files\ and the complete path to mysql.exe is C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql.exe .
To add mysql.exe to PATH environment variable follow these steps:
Hit Win+Pause/Break. This will open System Properties Window.
Click on Advanced system settings.
At the bottom of the newly opened window click on Environment Variables.
In the new window Select Path environment variable and click Edit.
Add ; at the end of the current variable value and append C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql.exe (the exact may differ depending upon version and architecture of the application). Click OK to save.
Now start the Command Prompt and enter the following command:
If you get the MySQL version as shown in the output, then it means everything is working alright and you have successfully installed MySQL Server. To login into the MySQL server use the following command:
You will then be asked for a password. On success, on you get the following output:
To quite the MySQL shell hit \q .
Install MySQL in Debian/Ubuntu/Mint #
To install MySQL on Debian based system like Ubuntu or Mint type the following command:
If you are using a Redhat based system like Fedora or CentOS use the following command:
The installer will automatically add the path to MySQL executable to the PATH environment variable so you don’t need to do anything.
Testing the Installation #
To the installation run the following command:
If you get the version of MySQL then it means you have successfully installed MySQL server.
After the installation MySQL server will start automatically. At anytime, we can check the status of the MySQL server using the following command:
You can stop the server using the following command:
For Redhat/Fedora/Cent OS:
To restart the server use the following command:
For Redhat/Fedora/Cent OS:
Installing MySQL on Mac OS #
To download MySQL for Mac OS visit https://dev.mysql.com/downloads/mysql/ and download the DMG archive.
Double-click the installer to start and go through the usual installation process. After the successful installation, you will be provided a temporary password to login into MySQL server. The temporary password is not recoverable so make sure to copy and save it in the safe place.
The MySQL installer usually installs the files in the directory named mysql within /usr/local/ . Just like Windows, MySQL installer for Mac doesn’t add MySQL executable to the PATH environment variable. Consequently, we have to execute MySQL by specifying the full path to it in the terminal.
We are now ready to start the server. Open System Preference and click on the MySQL icon.
This will open MySQL preference pane.
As the screen shows, currently, MySQL server is not running. Click Start MySQL Server button to start the server.
To login to the MySQL server enter the following command in the terminal.
You will then be prompted for a password. Enter the temporary password you copied at the time of installation and hit Enter.
Once you are inside the terminal, change your password using the following command.
To quit the MySQL shell enter \q .
Adding MySQL to Path Environment Variable in Mac OS #
To add MySQL executable to the PATH environment variable open .bash_profile and add the following code at the end of the file.
.bash_profile
Logoff and then login again for the changes to take effect. To verify the changes try running MySQL with without specifying the full path to it, as follows:
If you get the MySQL version then it means you have successfully added MySQL to PATH environment variable. You should now have MySQL server on your Mac OS up and running.
How did this guide work for you? If you are encountering any error let me know in the comments.
Getting MySQL path in command prompt
How can I get the mysql installation path up to bin folder using command prompt in windows.Is there any command to get the location of mysql installation path?
13 Answers 13
(if I get your question correctly) Like you wold add any other directory to path
It doesnt metter if you add %PATH% on, beginig or on the end, but you must add it, otherwise your path will only be your new directory.
Find mySql installation directory ( for example C:\Program Files\MySQL\MySQL Server 5.6\bin) and then type the comand above set PATH=%PATH%;C:\Program Files\MySQL\MySQL Server 5.6\bin
in cmd use PATH to see what is your path (I think every body knows this, but it cant hurt) And see something more about PATH command
Your mySql servce must be turned on to execute commands.
In a MySQL client you can get base and data directories by doing the following:
You can prob reconstruct all other paths from those. So if you can get to MySQL at all, that should do it.
Usually it is installed in side program file this is the normal path where you can find bin C:\Program Files\MySQL\MySQL Server 5.5\bin
I know this question is VERY OLD. but i just wanted to POINT OUT how all the answers here have COMPLETELY MISUNDERSTOOD the question of the OP.
Hes not asking HOW TO CHANGE THE PATH. he is asking if there is a way to get the path to the MYSQL INSTALL DIRECTORY ( BECAUSE IT CAN VARY FROM PC TO PC, x64 x86, driver letters ETC. ). the GOAL is similar to the @@basedir system variable in MySQL (BUT THIS REQUIRES you are connected to MySQL).
I think what the OP is trying to do and what i am trying to do is SIMILAR. WE wanted to get the BIN folder in MySQL directory in order to call mysqldump.exe. (please dont tell me to just use $ mysqldump.exe as this is used in the MySQL PROMPT not DOS PROMPT)
For example %MYSQLDIRECTORY% / BIN / mysqldump.exe
If you install mysql properly then mysql path is automatically added to environment variables. To check this type path in command prompt. If you can see mysql path in it, you can run mysql executable files from any command prompt location.
This worked for me and is very simple.
First I downloaded the mysql and did the full install, then performed the steps below.
On the Windows desktop, right-click the My Computer icon, and select Properties.
Next select the Advanced tab from the System Properties menu that appears, and click the Environment Variables button.
Under System Variables, select Path, and then click the Edit button. The Edit System Variable dialogue should appear.
Place your cursor at the end of the text appearing in the space marked Variable Value. (Use the End key to ensure that your cursor is positioned at the very end of the text in this space.) Then enter the complete path name of your MySQL bin directory (for example, C:\Program Files\MySQL\MySQL Server 5.1\bin)
Note
There must be a semicolon separating this path from any values present in this field.
Dismiss this dialogue, and each dialogue in turn, by clicking OK until all of the dialogues that were opened have been dismissed.
Now type «mysql — version» in the console, if it shows the installed version, everything went fine.
* You should not add the MySQL bin directory to your Windows PATH if you are running multiple MySQL servers on the same machine.
First of all:
Take extremelly care when editing your system Path variable; accidental deletion or modification of any portion of the existing Path value can leave you with a malfunctioning or even unusable system.
As we follow, I think I’ll need to explain a bit of how you can edit you Windows Path Variable. So, let’s begin.
Windows Path Variable
To start, we need to edit the Path System Variable, but how do we can edit it? Simple! Go to your Computer and click on its icon, then click on Properties.
Or you can just press Windows + Pause/Break , and then this window should open:
Then click on Advanced System Settings, or something similar, like in the following image:
After that, click on the System Variables button on the window that just opened.
At this new window you’ll find two areas, being the top and bottom one; For now let’s focus on the bottom one. Search for the variable, of name, Path. Click on it (select it), click on the Edit button and a window like the following should appear.
PS.: It’s important to have in mind that a Window like this will not open to you if you are using a Windows Version older than the 8 or 8.1, as I remember. It can have been changed, but I don’t know.
If you see this window you can now edit your Path System Variable by Adding or Removig directories, for now click on the Edit Text button. At this new window that opened, on the value field, at the final of the text that already is there, you should put this:
Listen, this is the default install location of the MySQL Servers that I’ve used. Now your gonna need to know where did you installed it. If you installed in the default location but you don’t know the version that you’re using, you can go to:
And see for yourself the version that you’ve installed and then put on the path above. For me I’ve used the following:
I’ve used that because my MySQL version is 5.7. I hope you got it.
Now Click on the Ok Button, until you don’t see any of the windows that we have opened.
Reopen your CMD (or Powershell), and now you can use your MySQL directly from the CMD.