How to Get mysql_config_editor - mysql

I ran sudo apt-get install mysql-client and it installed correctly. Then I ran mysql_config_editor print and I got
mysql_config_editor: not found
mysql_config_editor does not show up in /usr/bin like I expect it to, and like it does on my other machine.
On the machine where it worked, mysql --version shows
mysql Ver 8.0.21-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu))
On the machine where it doesn't work, mysql --version shows
mysql Ver 15.1 Distrib 10.1.45-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
How can I install a version of mysql that comes with mysql_config_editor or install the mysql_config_editor utility itself?

On MariaDB, as we have not a utility like mysql_config_editor to create ~/.login.cnf with obfuscated passwords, neither MariaDB reads it, one could degrade to ~/.my.cnf file with plain text:
[client]
user=my_username
password=my_password
#port=mysql_port
#socket=my_socket
#database=my_default_dbname
And then change access modes:
chmod 600 ~/.my.conf
Now only you can read this plain text file.
This avoids you to type user and password on command line on debian os in an insecure way, readeable by ps command.
mysql
Ref. https://mariadb.com/kb/en/configuring-mariadb-with-option-files/

Unfortunately MariaDB does not support this feature as explained here : https://mariadb.com/kb/en/mysql_config_editor-compatibility/
MariaDB is a fork of MySQL. So you can use its client to connect to a MySQL DB but it lacks the mysql_config_editor option.
Installing a MySQL client with mysql_config_editor is covered here : https://askubuntu.com/a/708606/943405
But I strongly advice you to uninstall the MariaDB client before and reinstall the full MySQL client to avoid troubles.
If you can't uninstall the MariaDB client then your solution is the best.

Related

For easy shell MySQL (Mariadb) access the "_my.cnf" file does not work

I've installed a recent version of MariaDB on my CentOS 8:
mysql Ver 15.1 Distrib 10.5.8-MariaDB, for Linux (x86_64) using readline 5.1
Given that I've changed the root password to something more complex, I'd like to not have to type it every time I SSH into the server and access this file. So I've created a _my.cnf file in my own user's /root folder:
[client]
user="root"
password="PASS"
[mysqldump]
user="root"
password="PASS"
However, this doesn't seem to work anymore. With this in place I expect to only write "mysql" at the command prompt and it would know to find the user and the password.
It's not working this way. Any ideas on what step I'm missing?
Thanks!
As helpfully mentioned by Progman, the filename should be .my.cnf.

How to determine if MySQL install is Community or Enterprise without root password?

I have taken over a production Linux RHEL server which has a MySQL install on it. I need to find out which version of MySql is installed.
Apparently this is easy information to determine which it says here on mysql.com but unfortunately no one can remember the root password and no one knows what version of MySQL it is.
I am assuming it is Enterprise but I need to know for sure.
I tried 2 different commands:
mysql --version
Output:
mysql Ver 14.14 Distrib 5.6.13, for Linux (x86_64) using EditLine wrapper
and
file /usr/sbin/mysqld
Output:
/usr/sbin/mysqld: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
Both of these commands provided me with useful information but I still need to figure out if the server has the Community or Enterprise edition.
No , you can't. You need to login to mysql to get this info.
Can use commands like,
SHOW VARIABLES LIKE "%version%";
You can get the details using status command in the mysql command prompt. Don't use the windows cmd prompt to execute the command.
mysql > Status

Alternative ways to store data base into a file

What can I use instead of mysqldump to extract information from db to any file?
I need to give back my computer and save information from it. Buy when I tried to save data base I had I faced a problem:
$mysqldump5 x -u root > x.150124.sql
mysqldump: Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=1': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OPTION SQL_QUOTE_SHOW_CREATE=1' at line 1 (1064)
In internet people face such a problem because they have new mysql and old mysql dump. And they recommend to install mysql56. My versions looks similar:
$ mysqldump5 --version
mysqldump Ver 10.13 Distrib 5.1.66, for apple-darwin11.4.2 (i386)
$ mysql5 --version
mysql5 Ver 14.14 Distrib 5.1.66, for apple-darwin11.4.2 (i386) using readline 6.2
but nevertheless I tried to install mysql56 using MacPorts (similarly to my previous mysql installation) and failed to do it because of errors py27-setuptools stage. All this problems looks quite complicated to solve and it is not guarantied that new problems wouldn't appear and I need the result quickly.
So I ask if there any other ways to store DB information. I don't really care about "clean solutions" and state of the system afterwards, since it will be reinstalled in any-case.
How about
select ... into ... outfile
here is more info on it...http://dev.mysql.com/doc/refman/5.1/en/select-into.html
edit: even better link http://www.mysqlfaqs.net/mysql-faqs/Data-Back-Up/Export-Data/How-to-use-SELECT-INTO-OUTFILE-statement-to-export-data
The quickest way, which I found is to stop current server:
mysqladmin5 shutdown
and install mysql5.6.22 from dmg package (mysql community server for osx10.9), avoiding mac ports.
After that
/usr/local/mysql-5.6.22-osx10.8-x86_64/bin/mysqldump -u root x > ~/x.150125.sql
did the job.
P.S. I don't accept this answer because it doesn't provide alternative solution for dumping. Therefore I accepted #Jose Martinez despite I didn't used that solution.

How to run MySQL server automatically on system startup on Mac OS?

Every time I want to use mysql first time after running my computer, I need to start the server manually by doing
mysql.server start
in the command line.
My question is - how can I make it to run automatically during the system startup?
I was looking for some answer and found only a way to do it on Ubuntu/Debian Linux, however this way (using update-rc.d) does not work on Mac OS.
mysql --version gives me
mysql Ver 14.14 Distrib 5.6.13, for osx10.9 (x86_64)
Try installing the Mac MySQL startup item. This adds a system prefs button and allows you to set this via a gui.
http://dev.mysql.com/doc/refman/5.1/en/macosx-installation-startupitem.html
Alternatively add (see link)
MYSQLCOM=-YES-
to
/etc/hostconfig

Find out where MySQL is installed on Mac OS X

How do I find out where MySQL is installed on Mac OS X 10.7.9? I have MAMP installed so I presume that it is bundled with this install?
To check MySQL version of MAMP , use the following command in Terminal:
/Applications/MAMP/Library/bin/mysql --version
Assume you have started MAMP .
Example output:
./mysql Ver 14.14 Distrib 5.1.44, for apple-darwin8.11.1 (i386) using EditLine wrapper
UPDATE: Moreover, if you want to find where does mysql installed in system, use the following command:
type -a mysql
type -a is an equivalent of tclsh built-in command where in OS X bash shell. If MySQL is found, it will show :
mysql is /usr/bin/mysql
If not found, it will show:
-bash: type: mysql: not found
By default , MySQL is not installed in Mac OS X.
Sidenote: For XAMPP, the command should be:
/Applications/XAMPP/xamppfiles/bin/mysql --version
It will be found in /usr/local/mysql if you use the mysql binaries or dmg to install it on your system instead of using MAMP
If you run SHOW VARIABLES from a mysql console you can look for basedir.
When I run the following:
mysql> SHOW VARIABLES WHERE `Variable_name` = 'basedir';
on my system I get /usr/local/mysql as the Value returned.
(I am not using MAMP - I installed MySQL with homebrew.
mysqldon my machine is in /usr/local/mysql/bin so the basedir is where most everything will be installed to.
Also util:
mysql> SHOW VARIABLES WHERE `Variable_name` = 'datadir';
To find where the DBs are stored.
For more:
http://dev.mysql.com/doc/refman/5.0/en/show-variables.html
and
http://dev.mysql.com/doc/refman/5.0/en/server-options.html#option_mysqld_basedir
If you downloaded mySQL using a DMG (easiest way to download found here http://dev.mysql.com/downloads/mysql/) in Terminal try: cd /usr/local/
When you type ls you should see mysql-YOUR-VERSION. You will also see mysql which is the installation directory.
Source: http://geeksww.com/tutorials/database_management_systems/mysql/installation/how_to_download_and_install_mysql_on_mac_os_x.php
If you've installed with the dmg, you can also go to the Mac "System Preferences" menu, click on "MySql" and then on the configuration tab to see the location of all MySql directories.
Reference: https://dev.mysql.com/doc/refman/8.0/en/osx-installation-prefpane.html
for me it was installed in /usr/local/opt
The command I used for installation is brew install mysql#5.6
Or use good old "find". For example in order to look for old mysql v5.7:
cd /
find . type -d -name "mysql#5.7"
For me I was able to get the location at the path "/opt/homebrew/etc"
I have installed mysql using homebrew.
If you are not able to get the exact path start the mysql server -> mysql.server start
then run mysql -v to check the version, it will bring you in to the mysql.
run SHOW VARIABLES WHERE Variable_name = 'basedir'.
Navigate to path "/opt/homebrew/etc"