Confusion in MySQL versions - mysql

I have a machine that had a running version of MySQL 5.6 used in an apache tomcat Java app. I needed to install WampServer 3.1 for a PHP project which comes with a MySQL 5.7.
I read that I have to change the port of wampserver MySQL to keep everything working as they were. I changed it to 3308 as suggested by wamp.
However, now I can't use mysql through cmd. I reverted back to port 3306, I can now use mysql.
The confusion however is that typing in the cmd:
mysql --version
returns
mysql Ver 14.14 Distrib 5.6.26, for Win64 (x86_64)
but using this command from MySQL:
SELECT VERSION();
returns
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.19 |
+-----------+
1 row in set (0.00 sec)
I tried uninstalling wampserver, but then I couldn't user mysql again. So I re-installed.
I don't want to use MySQL 5.7 with the apache tomcat Java app as it might cause problems with the projects if MySQL version migration is not done properly and it is something that I can't afford now.
If possible, can I keep both wampserver and MySQL 5.6? If not, how can I revert the situation?
Edit: when typing in cmd:
where mysql
it returns
C:\Program Files\MySQL\MySQL Server 5.6\bin\mysql.exe
but the version is as mentioned above 5.7

Related

How to Get mysql_config_editor

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.

mysql from windows cmd opens old version

I use windows and I have previously installed mysql 5.5 for some legacy project, and now I want to use 5.7 for a new one, so I installed 5.7 in another directory, on another port and having different data directory, my problem is when i launch mysql from cmd like:
W:\MySQL57\bin> mysql -u root -p
It results in this:
W:\MySQL57\bin>mysql -u root -p
Enter password: *****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.54-log MySQL Community Server (GPL)
And I am definitely sure that MySQL57 is directory for 5.7 MySQL, so what's wrong with mysql command line tool and how can i fix it to be able to use both mysqls in cmd?
The mysql command you are using is probably the 5.7 version, you can check this with :
W:\MySQL57\bin>mysql -v
But this is just the client !
The problem is your server version, you may have 2 versions running (5.5 and 5.7), and as you haven't specified the port you are using the default one which is used by the first server (5.5).
Try to find the port for the second version (3307 ?) or kill the 5.5 server when you are connecting to the 5.7.
You are calling the default mysql set in Environment Variable. If you want to use a specific mysql, you need to provide the path too
W:\MySQL57\bin>"W:\MySQL57\bin\mysql" -u root -p
In case of mysql not working, you can call mysqld.
If you want mysql 5.7 to be default, just change it from Environment Variable https://dev.mysql.com/doc/mysql-windows-excerpt/5.7/en/mysql-installation-windows-path.html

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

Logging in MariaDB in Centos

I am using Centos 6.5 and have just installed MariaDB-sever and MariaDB-client a while ago.
The first problem is that I start MariaDB by the command /etc/init.d/mysqld start instead of /etc/init.d/mysql start (because there is no mysql file in init.d). So currently I am baffled because I don't know what I started is MySql or MariaDB.
That leads to the second problem. According to their Knowledge base, I tried mysql -u root -p to log in. But it displayed MySql instead of MariaDB, about which I feel wrong:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.73 Source distribution
MySQL [(none)] >
So, am I running MariaDB or MySQL?
Yes, what you have started is wrong - it is running MySQL 5.1.73. You should uninstall your "distribution" provided MySQL (which ships with CentOS 6.5) and just install MariaDB.
You can do this by looking at: rpm -qa |grep -i mysql and removing those packages. Just do a clean install of MariaDB and you should be fine.
Some distributions ship /etc/init.d/mysqld, some - /etc/init.d/mysql . It makes no difference, just different script names.
MariaDB origins from MySQL, so if you see MariaDB in the prompt then it's MariaDB. You will never see MariaDB in Oracle's MySQL.

MySQL error 2006 MySQL server has gone away after upgrade to 5.6.10 using homebrew on Max OS X 10.8.3

I upgraded my installation of MySQL on my Mac OS X 10.8.3 using homebrew
brew install mysql
Everything seemed to go smoothly, but...not really, as it turns out.
I cannot add a new user (neither through the command line nor through phpmyadmin. I always get the error
Error in processing request: #2006 MySQL server has gone away
I can create new databases without a problem, and I can install, for example Joomla 3.1.1 with no problems.
However, when I try to install a new extension into my Joomla installation, I get errors. For example, I get the following error when I try to install a component from NoNumber:
1062 Duplicate entry '1' for key 'PRIMARY' SQL=INSERT INTO `u5z87_extensions` (`name`,`type`,`element`,`folder`,`client_id`,`enabled`,`access`) VALUES ('plg_system_nnframework','plugin','nnframework','system','0','1','1')
Same thing for many other extensions.
I tried to start mysql with
mysql.server start --log-warnings=2
and it started with no problem
Starting MySQL
SUCCESS!
I looked up issues where error #2006 were being reported and how to solve them, and they referred to modifying /etc/my.cnf but there is no /etc/my.cnf configuration file on my system, and there wasn't one in the previous installation of MySQL 5.5.29 (also installed with homebrew) and I had no problems.
I ran brew doctor and the output is below
$ brew doctor
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/usr/local/opt/php54/bin/php-config
The output from brew --config is also below:
$ brew --config
HOMEBREW_VERSION: 0.9.4
ORIGIN: https://github.com/mxcl/homebrew
HEAD: 86ce842c700a47abdc354e80cc3b0b3938ab2132
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: 8-core 64-bit nehalem
OS X: 10.8.3-x86_64
Xcode: 4.6.2
CLT: 4.6.0.0.1.1365549073
LLVM-GCC: build 2336
Clang: 4.2 build 425
X11: 2.7.4 => /opt/X11
System Ruby: 1.8.7-358
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: /Users/alisamii/.rvm/rubies/ruby-1.9.3-p374/bin/ruby
Exploring a little further, I tried to revert to my previous install of MySQL using
brew switch mysql 5.5.29
This resulted in the following output:
$ brew switch mysql 5.5.29
Cleaning /usr/local/Cellar/mysql/5.5.29
Cleaning /usr/local/Cellar/mysql/5.6.10
135 links created for /usr/local/Cellar/mysql/5.5.29
I then accessed mysql from the command line and ran status:
mysql> status
--------------
mysql Ver 14.14 Distrib 5.5.29, for osx10.8 (i386) using readline 5.1
Connection id: 13
Current database:
Current user: alisamii#localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.6.10 Source distribution
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql.sock
Uptime: 1 hour 56 min 24 sec
As you can see above, it reports mysql Ver 14.14 Distrib 5.5.29, for osx10.8 (i386) using readline 5.1
But, it also says Server version: 5.6.10 Source distribution
So something isn't syncing up.
Furthermore, when I show databases, I get the following output:
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)
But I know I have more than just an information_schema database.
So, somehow, it seems to me that mysql is not connecting to the right server, as phpmyadmin reports the same server information that mysql's status command reports: Software version: 5.6.10 - Source distribution.
At this point, I am completely lost, and would really need some help.
OK, so partially resolved the issue.
At the recommendation of https://stackoverflow.com/users/201789/tehshrike I read the pages related to mysql_update and followed the recommendations there.
Upgrading MySQL does not upgrade the information_schema, and so some things don't work. This command helps fix some of those issues.
Now, I can add new users and the #2006 - MySQL server has gone away error is no longer an issue.
However, I am still getting the #1062 errors when trying to install extensions in Joomla, for example. Still exploring solutions to that. Will update this answer with details when solved.