Debian 9 how to install MariaDB without MySQL nameing? - mysql

I'm going thru this instrucion, trying to keep data collected from DHT22 temperatur/humidity sensor on my RaspberryPi2 with Raspbian (Debian9) onboard.
But when it comes to install and use of the DB server, when i try to install MySQL, apt-get installs MariaDB.
From this and this link I know why, but i don't want to use MySQL name in my later scripts if my procedures really uses MariaDB.
So please tell my how change below commands to instal MariaDB directly, and login to DB interface without using MySQL name:
sudo apt-get install mysql-server python-mysqldb
mysql -u root -p -h localhost

With those commands MariaDb is the default install for Debain 9. So all you need to do now is
apt-get install phpmyadmin and mysql_secure_installation. Then you can login and access the interface at localhost/phpmyadmin

Related

When Ubuntu 18.04 deploys zabbix4.0, the database type is PostgreSQL instead of MySQL. How can I set this to support MySQL?

In Ubuntu 18.04 server, I use binary file to install zabbix4.0 according to the official website document of zabbix4.0, and I use MySQL 5.7.30 database. After installation, when I configure the front end of zabbix4.0,In the database configuration page, I only see one option of PostgreSQL, not mysql, as shown in the following figure:
In my server, I have installed MySQL version 5.7.30, and imported the data of ZABBIX 4.0 into the ZABBIX database, without any PostgreSQL installed
Excuse me, how can I make zabbix4.0 support MySQL 5.7.30 that I have installed? Thank you!
I installed zabbix4.0 according to the official documents:
https://www.zabbix.com/documentation/4.0/zh/manual/installation/install_from_packages/debian_ubuntu
This is my installation method:
# install zabbix
cd ~/download
wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-
release/zabbix-release_ 4.0-2+bionic_ all.deb
sudo dpkg -i zabbix-release_ 4.0-2+bionic_ all.deb
sudo apt-get update
#install Server/proxy/
sudo apt-get install -y zabbix-server-mysql
sudo apt-get install -y zabbix-frontend-php
With Ubuntu, you got two type of databases when donwloading Zabbix, PostgreSql and MySql. You need to re-download (I mean installation and configuration) Zabbix choosing MySql as database.
The following link could help Zabbix (Ubuntu) with MySql as database
The current version of the package is 4.0-3, so instead, you must do this :
Install repository
# wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-3+bionic_all.deb
# sudo dpkg -i zabbix-release_4.0-3+bionic_all.deb
# sudo apt update
Install server, frontend, agent
# sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent

Connect to RDS MySQL instance from ec2 Linux AMI - mysql command not found

I try to connect to my RDS MySQL instance from an SSH connection to my ec2 server (through PUTTY) as outlined here:
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToInstance.html#USER_ConnectToInstance.CLI
But I get:
-bash: mysql: command not found
I think maybe I have to install the MySQL Utility client on my ec2 linux server? If this is the case how do I do this?
I try to run the mysql command from my /home/ec2-user directory.
When using Amazon Linux 2 AMI, we need to install mysql. Use this command to install mysql on the instance:
sudo yum install mysql
And then you can connect using this command:
mysql -h change-to-your-rds-endpoint.rds.amazonaws.com -u <USER> -p
Install mysql client on AWS Linux EC2:
$ sudo yum install mysql
Connect:
$ mysql -h endpoint -P port -u masteruser -p
If you enter your password and nothing happens, check your security groups. You may need to edit your inbound rules.
First install mysql into your ec2 instace using below command
sudo apt-get install mysql-server mysql-client
After installing mysql try with below cmd to connect RDS
mysql -h hostname -u username - p password
You'll need to install MySQL. Amazon AMIs use yum instead of apt so use:
sudo yum install mysql-server mysql-client
if you are working to setup a LAMP (Linux, Apache, MySQL, PHP) server then follow these instructions http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html
Install the mysql client lib with the package manager of your system, for example on Ubuntu:
apt-get install mysqlclient

How do I install command line MySQL client on mac?

I want to install the MySQL client for the command line, not a GUI. I have searched over the web but only found instructions on installing the MySQL server.
install MySQLWorkbench, then
export PATH=$PATH:/Applications/MySQLWorkbench.app/Contents/MacOS
This strictly installs a command line client, without the other overhead:
Install Homebrew (if you don't have it):
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then, install mysql-client:
brew install mysql-client
Then, add the mysql-client binary directory to your PATH:
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
Finally, reload your bash profile:
source ~/.bash_profile
Then you should be able to run mysql in a terminal, if not try opening a new terminal
If you have already installed MySQL from the disk image (dmg) from http://dev.mysql.com/downloads/), open a terminal, run:
echo 'export PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile
then, reload .bash_profile by running following command:
. ~/.bash_profile
You can now use mysql to connect to any mysql server:
mysql -h xxx.xxx.xxx.xxx -u username -p
Credit & Reference: http://www.gigoblog.com/2011/03/13/add-mysql-to-terminal-shell-in-mac-os-x/
Best option is:
brew install mysql
Mysql has a client-only set of utilities:
Mysql client shell
https://dev.mysql.com/downloads/shell/
Other command line utilities
https://dev.mysql.com/downloads/utilities/
Mac OSX version available.
There is now a mysql-client formula.
brew install mysql-client
For installing mysql-shell with homebrew, run
brew cask install mysql-shell
you can then launch the mysql shell with
mysqlsh
if you want to enter SQL mode directly, run
mysqlsh --sql
Open the "MySQL Workbench" DMG file and
# Adjust the path to the version of MySQL Workbench you downloaded
cp "/Volumes/MySQL Workbench 6.3.9.CE/MySQLWorkbench.app/Contents/MacOS/mysql" /usr/local/bin
# Make sure it's executable
chmod +x /usr/local/bin/mysql
Eject the DMG disk
Installation command from brew:
$ brew cask install mysql-shell
Look at what you can do:
$ mysqlsh --help
Run query from mysqlsh client installed:
$ mysqlsh --host=192.x.x.x --port=3306 --user=user --password=xxxxx
MySQL Shell 8.0.18
Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
Type '\help' or '\?' for help; '\quit' to exit.
WARNING: Using a password on the command line interface can be insecure.
Creating a session to 'user#192.x.x.x:3306'
Fetching schema names for autocompletion... Press ^C to stop.
Your MySQL connection id is 16
Server version: 8.0.18 MySQL Community Server - GPL
No default schema selected;
type \use <schema> to set one.
MySQL 192.x.x.x:3306 ssl JS >
MySQL 192.x.x.x:3306 ssl JS > `\use rafdb`
Default schema set to `rafdb`.
If you installed from the DMG on a mac, it created a mysql client but did not put it in your user path.
Add this to your .bash_profile:
export PATH="/usr/local/mysql/bin:$PATH
This will let you run mysql from anywhere as you.
As stated by the earlier answer you can get both mysql server and client libs by running
brew install mysql.
There is also client only installation. To install only client libraries run
brew install mysql-connector-c
In order to run these commands, you need homebrew package manager in your mac. You can install it by running
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Using MacPorts you can install the client with:
sudo port install mysql57
You also need to select the installed version as your mysql
sudo port select mysql mysql57
The server is only installed if you append -server to the package name (e.g. mysql57-server)
The easiest way would be to install mysql server or workbench, copy the mysql client somewhere, update your path settings and then delete whatever you installed to get the executable in the first place.
The mysql client is available in macOS ports. If you don't have this excellent third party package manager already installed, it is available from here: https://www.macports.org/
Once you have installed macports, open a terminal and make sure everything is up to date:
sudo port selfupdate
There are multiple different versions of MySQL and mariadb (community fork of MySQL) available in the ports repos. List available versions using the following command:
port search 'mariadb*'
I recommend choosing mariadb over mysql as it is, mostly, a drop in replacement (https://mariadb.com/kb/en/mariadb-vs-mysql-compatibility/) and has excellent community support.
If applicable, choose which version of mariadb you want (a list of versions of mariadb is available here: https://downloads.mariadb.org/mariadb/+releases/). If you're not bothered, install the default version:
sudo port install mariadb
Mariadb (including the mysql-compatible command line client) is now available on your system. On my system, the CLI client resides in the following location:
$ /opt/local/bin/mysql --version
/opt/local/bin/mysql Ver 15.1 Distrib 5.5.68-MariaDB, for osx10.15 (x86_64) using readline 5.1
It's obviously a bit inconvenient to type out the full path, /opt/local/bin/mysql each time you want to use the client. Ports has already thought of this problem. To view available versions of mysql on your system, run:
$ port select mysql
Available versions for mysql:
mariadb (active)
none
Choose one from the list. For example, to use mariadb as the default mysql client:
sudo port select mysql mariadb
Now open a fresh terminal window and you should be able to start the mariadb mysql CLI client:
mysql -h <hostname> -u <username> -p
if you need a lighter solution i recommend mysql-shell, install using the command below.
brew cask install mysql-shell
To start after installation type mysqlsh.

Mysql version is different in phpmyadmin

I just upgraded my MYSQL version from
5.5.40 to 5.6.22
but my PHPMYADMIN still show the same old version on Home Page
In terminal I checked version
mysql --version ==> 5.6.22
But when I check with "select version()" command inside Terminal and PHPMYADMIN
I got correct version 5.6.22
But on home page of PHPMYADMIN I get 5.5.40-0ubuntu0.14.04.1 - (Ubuntu)
In a post I read that there might be two mysql clients installed and may be phpmyadmin is referring to old client. If this is the case how can I delete old-client
Try removing php-mysql and installing php-mysqlnd. Will automatically done by following commands
sudo add-apt-repository ppa:nijel/phpmyadmin
sudo apt-get update
sudo apt-get install php5-mysqlnd
sudo apt-get --purge --reinstall install phpmyadmin
Or you can try reinstalling your phpmyadmin

How can Upgrade MySQL 5.5.40 to MySQL 5.7

How can I Upgrade MySQL version
Current MySQL Version: 5.5.40
Target MySQL Version: MySQL 5.7
OS: CentOS release 6.5 (Final)
Probably the quickest way is to dump your older DB version with mysqldump and restore it into 5.7 fresh DB.
How smooth the process goes, depends on how many dropped features in 5.7 you're using in 5.5.
In my case, the only feature, that was dropped in 5.7 was timestamp default '0000-00-00 00:00:00'
The fix for that was to run sed on dump file and replace ''0000-00-00 00:00:00' with CURRENT_TIMESTAMP
sed -i.bu 's/'\''0000-00-00 00:00:00'\''/CURRENT_TIMESTAMP/g' fixed_dumo.sql
Afterthat, the fixed_dump.sql was imported into fresh 5.7 DB and it worked smoothly.
I hope this helps.
The upgrade path is MySQL 5.5 -> MySQL 5.6 -> MySQL 5.7
See https://dev.mysql.com/doc/refman/5.7/en/upgrading.html
step 1 : take a backup
mysqldump --lock-all-tables -u root -p --all-databases > dump.sql
step 2 : remove old mysql
sudo apt-get remove mysql-server
sudo apt-get autoremove
step 3 : install new version of mysql 5.6
sudo apt-get install mysql-client-5.6 mysql-client-core-5.6
sudo apt-get install mysql-server-5.6
for 5.7
wget http://dev.mysql.com/get/mysql-apt-config_0.6.0-1_all.deb
sudo dpkg -i mysql-apt-config_0.6.0-1_all.deb
sudo apt-get update
sudo apt-get install mysql-server
step 4 : edit your data to address differences between versions (5.5 and 5.7)
If you have create table and timestamp(6) column is used than default values should be changed from CURRENT_TIMESTAMP to CURRENT_TIMESTAMP(6)
`event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
step 5 : restore your data
mysql -u root -p < dump.sql
step 6 : Try to add a new db user. To validate and fix issues introduced from import of system tables like users (ERROR 1805 (HY000): Column count of mysql.user is wrong.)
mysql_upgrade -u root -p
I might be late to the party, but easy and fast solution without or minimal downtime could be AWS Database-Migration-Service, which can be used to upgrade your database to a different version as well as to some other server or RDS.
I have tried this and converted MySQL5.5 to MySQL5.7 on production without any downtime.
Here is a demo for the same - How To Migrate MySQL5.5 to MySQL5.7
Steps:
Set your current MySQL as master
Create a new instance/server with MySQL5.7 on it with required users
Got to AWS DatabaseMigrationService (DMS) and create a Replication
instance
After creating replication instance it will ask to fill up connection
detail to source(MySQL5.5) and target(MySQL5.7) databases.
Create task in DMS, which will be the logic on what basis you want to
migrate the data (particular database or particular table)
Start the task
When task is completed and data is in sync, just switch the DNS entry
pointing to MySQL5.5 to MySQL5.7
Yes. From a "logical upgrade" you can migrate from 5.5 for 5.7. This way: 5.5 -> 5.6 -> 5.7, is necessary only for "in place" upgrade, with data folder.
See: https://www.percona.com/forums/questions-discussions/mysql-and-percona-server/43956-what-is-the-preferred-mysql-upgrade-path-5-5-to-5-7
Fallow Simple Steps for Upgrade Mysql Version 5.5 to 5.7 .
wget http://dev.mysql.com/get/mysql-apt-config_0.8.0-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.0-1_all.deb
sudo apt-get update
sudo apt-get install mysql-server
After a bunch of failed attempts I have concluded it down to:
To upgrade from 5.5, go to 5.6 first and then to 5.7
Save the datafolders and install a fresh installation of 5.7
Both need the apt-config mentioned in all above comments.
The kicker is to run sudo apt install mysql-**community**-server
in Mysql,
step 1: fetch version,
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
step 2:
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
step 3:
check available mysql repo,
yum repolist all | grep mysql
will get something like below,
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - S disabled
mysql56-community/x86_64 MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server - S disabled
mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 384
mysql57-community-source MySQL 5.7 Community Server - S disabled
Its preferred to upgrade one by one,
so first upgrade into mysql 5.5 into mysql5.6
step 4: first enable to mysql 5.6 and disable mysql 5.5 and 5.7
sudo yum-config-manager --enable mysql56-community
sudo yum-config-manager --disable mysql55-community
sudo yum-config-manager --disable mysql57-community
step 5: before upgrade stop service,
sudo systemctl stop mysql
step 6: Lets ready to upgrade,
yum update
you are successfully upgrade into mysql5.6
now repeat step 4 to 6 to upgrade into 5.7
sudo yum-config-manager --disable mysql56-community
sudo yum-config-manager --enable mysql57-community
and then
yum update
mysql --version
successfully upgraded into mysql 5.7 dont forgot restart service,
systemctl start mysql
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mysql-server-5.6