I'm developing an installer for my program for Windows OS.
I'd like the installer to check if MySQL is already installed and if it isn't silently install MySQL before installation is over.
How can I check if MySQL is already on the computer with delphi?
Regarding MySQL server:
As #Shirish11 sayd, you can check HKLM\SOFTWARE\MySQL AB. But that does not guarantee anything, as this registry key is optional. MySQL really does not require any "complex" installation procedure, like SQL Server. You can download MySQL as an installer, as just a ZIP archive. In last case the registry key will be not created. The similar with services. Using mysqld.exe --install Kitty --defaults-file=c:\mysql.cfg command line you can create MySQL service with Kitty name. Or even a service may be not created at all.
The MySQL server may be installed not locally, but on a different host. And be administrated by a dedicated DBA. So, you may not need to check / install server at all. Just not your task. If your application is going to install a local server, which will be used only by "this" workstation, then use MySQL Embedded.
In general, you should ask the user about MySQL installation, eg "Do you have MySQL server installed ?". And if user answers "yes", then you can ask him for login parameters (host, port, database, user name, password). If not, then you can suggest him to download it and install, to avoid licensing issues. Because you have to have a license, purchased from Oracle, to distribute the MySQL Server installer with your software.
Regarding MySQL client:
There is no other signs, that libmysql.dll is "installed", than the libmysql.dll presence. You can check for libmysql.dll at Windows folder, at PATH folders. More simple - you can always put it with your EXE.
If you are using dbExpress, then you should use specific libmysql.dll version, supported by EMBT dbExpress driver. So, again, better to put it with your EXE.
See note (3) regarding server licensing. It applies to client too.
Check for this registry entry for MySQL if present
HKEY_LOCAL_MACHINE\SOFTWARE\MySQL AB
If you have MySQL installed then this entry should be present.
If you need some thing more, then check for the service if its present
function ServiceIsPresent(sMachine, sService: PChar): Boolean;
var
SCManHandle, SvcHandle: SC_Handle;
begin
// Open service manager handle.
SCManHandle := OpenSCManager(sMachine, nil, SC_MANAGER_CONNECT);
if (SCManHandle > 0) then
begin
SvcHandle := OpenService(SCManHandle, sService, SERVICE_QUERY_STATUS);
// if Service installed
if (SvcHandle > 0) then
begin
Result := True;
CloseServiceHandle(SvcHandle);
end;
else
Result := False;
CloseServiceHandle(SCManHandle);
end;
end;
function call
ServiceGetStatus(nil,'MySQL');
I have picked up this service name from my registry entries
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services
But be careful while using service check because some people might have different service names for MySQL service.
As in my case I have 2 installations of MySQL hence 2 services are present MySQL,MySQL501.
Hence it will be bit tedious to find out the correct service name.
Mind you HKEY_LOCAL_MACHINE\SOFTWARE\MySQL AB can remain in registry even on uninstall of MySQL. What gets removed is HKEY_LOCAL_MACHINE\SOFTWARE\MySQL AB\MySQL Server 5.1 but since we do not know the MySQL Server 5.1 part in advance, its not easy to go for this approach. Moreover MySQL need not be installed as such.
What is possible is to check HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MySQL\ImagePath and then see if the path specified by the value exists. The second part is important because MySQL need not remove the service key during uninstallation if service is already turned off. So this registry value can remain even after uninstallation. So the best option is to get the path of the executable from the above mentioned registry and then see if the mysqld.exe or (whatever it is) exists. MySQL is not installed if either the registry value doesn't exist or if the file doesnt exist. The catch here is that this logic fails if MySQL is installed but not configured to start its service (which means there is no key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MySQL). But thats trivial, since running MySQL installations will anyway have it and most machines will have MySQL running. Now even if the installed MySQL is not configured to have a service, its quite okay to install another version of your MySQL and register your service first.
I'm unsure of a perfect solution, the reason being MySQL being not a proprietary software. I mean anyone can bundle MySQL and install in their own flavours. For example, wampserver comes with their own MySQL. Client machines most certainly wont have servers installed that way, but we can not rule out the option and we may not want another MySQL instance (Note that a separate instance of MySQL runs fine along with MySQL in wamp server). What I do is check the above, if I did not find, I check for the image path of wamp service, like HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\wampmysqld\ImagePath. It depends on the server you have on a machine.
Related
I have used mySQL for a project in the past, and haven't used it for months. However, when i check my task manager 'mysql' is using about 100MB of RAM. This happens every times i reboot. Why is my sql running, or using memory when i don't need it. Is a server running in the background that i have to disable? For context i was using my SQL Workbench 8.0 when working on my project.
Open a command prompt window cmd.exe
Stop MySQL service: net stop mysql57 (or net stop mysql)
Go to your mysql server installation path, in my case: cd "C:\Program Files\MySQL\MySQL Server 5.7\bin\"
Execute mysqld.exe --remove
This will remove the MySQL Service.
Note that You may need an elevated command line prompt, for that press WIN-X select Command Prompt (Admin)
Yes, MySQL Server service would be constantly running in the background, if (because) this service's startup type was set on an "automatic start when computer starts" mode during the installation of MySQL Workbench. The comment by #Alejandro offers the finest explanation.
(below steps I had tried for MySQL 8.0.30 version, however shall work with nearby versions as well; as steps to stop the service might be generic.)
In Windows 10, to stop the MySQL Server's service, OR, change the startup-type setting of MySQL Server.
Open Windows Services panel via the Start menu, OR, Win+R -> type services.msc, do Enter.
Different Windows OS's services would be listed here, alphabetically.
Find the MySQL Service. For MySQL 8 versions, it's often by default name - MySQL80, unless you had named it by a custom name during installation.
Click STOP, to stop the service.
On the other hand, you may choose your desired Startup type. By default, you'll find it on Automatic type.
If you want to keep Manual type, make sure to start the service by coming at this Services wizard, before using MySQL Workbench. Otherwise, the workbench won't be able to recognize/find the server.
While installing the MYSQL Server, this check box is by default checked (shown in the picture). If you uncheck this, then you need to start your MYSQL Server manually.
I installed mysql and apache. Apache is serving wordpress correctly and I want to install wordpress via install.php. This fails at setup step 2 after inserting database name, user and password (error 500).
I suspect that I haven't correctly finished the mysql database setup.
So to check, I log in to mysql via mysql -u root -p and run select database(); which returns null. So there is no database. Then when I call create database wordpress it says the db already exists. So what??
Just in case someone asks why not use xampp or wamp or the like: I want to set up everything by hand to learn the basics.
System setup: Windows 8.1 64 bit, mysql 5.7.21, apache 2.4, php 7.2.4 w/ thread safe
In the php.ini file you have to enable two settings:
extension = mysqli
extension_dir = "ext"
The root cause was that I had only activated the extension setting.
The website where I found this tip did not mention the requirement to also set the extension directory.
The final solution is from the official guide to install mysqli, which is very misleading in this regard:
For PHP > 5.3 it says
On Windows, for PHP versions 5.3 and newer, the mysqli extension is
enabled and uses the MySQL Native Driver by default. This means you
don't need to worry about configuring access to libmysql.dll.
But this was not true for me. It did not work out of the box.
For older versions (e.g. ones which should not affect my version) it says
As with enabling any PHP extension (such as php_mysqli.dll), the PHP
directive extension_dir should be set to the directory where the PHP
extensions are located. See also the Manual Windows Installation
Instructions. An example extension_dir value for PHP 5 is c:\php\ext.
This was the final hint that got it working.
Despites I've already installed XAMPP, I am trying to upload my database via MySQL server 5.7.17 since it's too big but both it and XAMPP use the same port - 3306. MySQL server is not even allowing me to continue to install it unless I make a change
SOrry, I'm a newbie.
Screenshots
Note It was suggested to me to download MySQL Server since I had already installed XAMPP but it didn't help me to upload my database.
No. If port 3306 is in use by an already installed and running MySQL instance, then another MySQL instance cannot use that same port. It is possible to run MySQL on a port other than the default 3306. But before we go there...
I think we might be barking up the wrong tree, trying to install another copy of MySQL and to run two instances of MySQL. Maybe we are wanting to run a different version of MySQL, other than the version other than what is included in the package we already installed.
But back pedal a bit here.
How is it that we reached the conclusion that installing another copy/version of MySQL was a viable solution to the problem we encountered?
It seems like we want to figure out the root cause of the original problem, before we chase down the wrong rabbit trail...
Specific Question: In a 2-3 week process of learning MySQL and attempting to get a Python stock info scrapping program to feed data into a MySQL schema (database, table) I’m having serious difficulties with connections. Having been bitten by doing something wrong & having to re-install MySQL about 8 times now, I’m getting rightfully leery of just about everything in the installation process. Thus this question:
Is “Local instance MySQL” which shows up in the upper left corner of the first (black) MySQL Workbench screen the proper one to use to connect to the database?
As a follow-up,
What is the difference between the windows service MySQL57, the connection MySQL57, and Local instance MySQL57?
During the very painful process of trying to get MySQL up and running, I think I've gotten further when with a fresh installation the first screen reads “MySQL57” as opposed to “Local instance …”
My setup parameters are pretty vanilla with the exception that I’m putting the MySQL program on my D: drive as opposed to the C: drive (an SSD reserved for the operating sys).
System: Windows 8 64bit on a Xeon Ivy Bridge processor, large SSD’s, large HD’s, mucho RAM, dual X-fired video cards, ASUS Sabertooth MB (self-built a yr ago)
Software: MySQL 5.7, complete installation except for module for Visual Basic and Python3 (running 2.7). Attempting to use the above hardware as both a server & client.
Even though I did my first Fortran programming in 1964, and spent my career on Unix machines, please regard me as a newbie when it come to the jargon associated with databases and client/server communications.
Why am I asking this question? My “down the road question” will be about getting data from Python into the MySQL table, but “first things first” --- I would like to get a nice clean installation that I can trust.
By the way, I’ve thoroughly scoured this site and many others but have not found any answers that fit my requirements; they’re either for a non-Windows environment, too full of jargon for me to understand, or too simplistic to be useful.
TIA, Doug
Seems there's some confusion about certain terms. So let's have a look at each:
MySQL is a server application that you can install and connect to via
TCP/IP (on any platform), named pipes (on Windows) or sockets (on
*nix like platforms). This server is totally independent and has no name or such for identification.
A Windows service to run the MySQL server: this is just a helper to allow running the server when your machine starts up. A service is not strictly necessary to run a MySQL server but without it you would have to manually start/stop the server. You can create as many service entries for a server as you want, but usually it makes no sense to create more than one. Since there can be more than one server (each with an own service) on the box it is highly recommended to give the services speaking names (like MySQL57 for a 5.7 MySQL server, MySQL56 or a 5.6 server etc.).
MySQL Workbench connections are entries that store parameters to connect to a MySQL server. They are not tied to a specific service in general (you can connect to a non-Windows server too), but might be associated with such a service if they are configured for a local server (on a Windows machine) and you want to be able to start/stop this server from within MySQL Workbench (see Administrator section). They use the service name to act on a particular service (you configure that in the Connection manager, System profile). On Windows MySQL Workbench attempts to find installed service (to help new users to get up and running quicker) when it is started and no connection is currently defined. It then automatically creates a connection for each service it found (it uses "mysql*" as pattern to search for services). You can retrigger this process by removing all connections and restart MySQL Workbench.
The created connnections (like the “Local instance MySQL”) appear as tile you can simply click to open that connection. Be aware that clicking on the rightmost 1/4 of the tile will open an information popup only, not open the connection as such.
Now to your question:
What is the difference between the windows service MySQL57, the
connection MySQL57, and Local instance MySQL57?
I don't understand where you see a connection MySQL57. There's usually only a service MySQL57 and connection in MySQL Workbench to the server this service is for involved.
I'm also not sure why this is such a dreadful process for you. Especially for Windows a lot of effort has been put into an easy installation experience. The normal process should be like:
Download the MySQL Installer
Run the installer. Select a typical scenario from the presets or select the individual products you want to have installed, say, a MySQL server + MySQL Workbench.
The installer will download and install the selected components.
Configure your server (like giving it a proper service name, TCP/IP port etc.).
After finishing the installer you start MySQL Workbench and can immediately work with your new server (as described above MySQL Workbench picks up the service automatically).
Depending on your download speed this should be something like a 5 - 10 mins. process.
HTH
with due respect sir , windows service mysql is a service created by windows upon successful to help you start / stop mysql. You can use Local Instance Mysql57 without a glitch, as that is just a way of MySQL representing your local mysql instance in the workbench.
I need to adapt our testing server to our production one that is stored on Aruba.
Aruba use MySql 4.0.30 but I can't find them nowhere!
Anybody know where can I find it ? or anybody has the installer stored anywhere?
Davide
According to http://lists.mysql.com/mysql/210800 (an email from a MySQL employee) this is a non-public release for customers who are too inflexible to upgrade. It says you can pay for "extended support" to get it.
Here for you source: http://mirror.provenscaling.com/mysql/community/source/4.0/mysql-4.0.30.tar.gz
Binaries only there for 4.1: http://mirror.provenscaling.com/mysql/community/binaries/4.1/
MySQL does not require much installation steps like most windows software.
Just copy the mysql dir and the mysql data dir from the production environment to your local machine and start mysqld.exe (does not need to be run as a service) from the bin directory with:
mysqld.exe --defaults-file="C:\path\to\my.ini" MySQL
If it does not start, you most likely tweak some path entries in your my.ini.
Or you can install the latest 4.x Server you find and replace the binaries and data files with the ones you get from production. That should totally do it.