update percona cluster from 5.6 to 5.7 - mysql

Based on percona update procedure (https://www.percona.com/doc/percona-server/5.7/upgrading_guide_56_57.html) you need to do :
sudo service mysql stop
sudo apt-get install percona-server-server-5.7
sudo mysql_upgrade
sudo service mysql restart
In my case I have a cluster with 3 nodes (multi-master):
My questions are :
Do I need to run mysql_upgrade on all nodes or only on first one upgraded ?
Is there any problem if until I complete update on all nodes some of them will run 5.6 and some 5.7 ?
Kind regards,
Silviu

I found the answer in the Percona XtraDB documentation: (https://www.percona.com/doc/percona-xtradb-cluster/LATEST/howtos/upgrade_guide.html)
Basically you have to do for each node in the cluster:
First open 2 ssh sessions
on session 1
sudo service mysql stop
sudo apt-get remove percona-xtrabackup* percona-xtradb-cluster*
sudo apt-get install percona-xtradb-cluster-57
sudo service mysql stop
cp /var/lib/mysql/grastate.dat /etc/www/grastate.dat
sudo mysqld --skip-grant-tables --user=mysql --wsrep-provider='none'
then go to sesison #2
open session 2
mysql_upgrade
sudo mysqld stop
sudo service mysql restart

Related

What's the correct way of installing MySQL on CentOS 6.6 on Compute Engine by Google?

I've been trying to install MySQL on CentOS 6.6 but with no good results. I have just created a new VM with these steps:
1.- sudo yum -y install mysql-server mysql
2.- sudo mysql -u root
RESULT .- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
also doing a "sudo service mysql start"
RESULT mysql: unrecognized service
Thanks mates !
Try
sudo /etc/init.d/mysqld start
or
sudo service mysqld start

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

Installing MySQL 5.6 in Amazon Linux Machine

I am trying to install MySQL 5.6 in amazon linux machine. by using following link.
after completing following steps.
sudo yum localinstall http://repo.mysql.com/mysql-community-release-el6-3.noarch.rpm
sudo yum install mysql-community-server
when i am starting mysql services by this command.
sudo service mysqld start
I am getting MySQL Daemon failed to start error.
Remove old mySql
sudo yum remove mysql mysql-server mysql-common mysql-client
remove all pre-installed packages. You can get a list:
rpm -qa | grep -i mysql
Then uninstall all of them. For example:
rpm -e mysql libmysqlclient15-5.0.94-0.2.4.1 <and so on>
Completely remove the /var/lib/mysql folder
cd /var/lib
rm -rf mysql
Installing fresh mySql 5.6 =>
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-5.6.23-1.el7.x86_64.rpm-bundle.tar
tar -xvf MySQL-5.6.23-1.el7.x86_64.rpm-bundle.tar
sudo yum -y install MySQL-client-5.6.23-1.el7.x86_64.rpm
sudo yum install MySQL-shared-compat-5.6.23-1.el7.x86_64.rpm
sudo yum install MySQL-server-5.6.23-1.el7.x86_64.rpm
Starting from 2015 Sep, Mysql 5.6 server is now natively available through Amazon yum repos. More info # https://aws.amazon.com/blogs/aws/now-available-amazon-linux-ami-2015-09/
You can now simply install Mysql 5.6 server using
sudo yum install mysql56-server
Then you can simply start/stop/status look using the regular service commands
service mysqld start ( restart | stop | status | )
I couldn't figure out the default root password in Amazon AMI then I simply reset the root user password by starting the mysqld service with skip grant tables
mysqld_safe --skip-grant-tables start
mysql -u root
update user set password=PASSWORD('[New Password]') where User='root';
OR
/usr/libexec/mysql56/mysqladmin -u root password 'new password'
Also, you need to run the following command to upgrade the MySQL database to 5.6
sudo mysql_upgrade -u root -p
I met the same problem on my micro instance. Check your mysql logs
If the issue is because of
InnoDB: Cannot allocate memory for the buffer pool
Adding a swap page might solve the problem. It solved for me.
You can follow this setup
http://www.prowebdev.us/2012/05/amazon-ec2-linux-micro-swap-space.html
I copied the contents if the page does not loads
Amazon EC2 Micro Instance Swap Space - Linux
I have a Amazon EC2 Linux Micro instance. Since Micro instances have only 613MB of memory, MySQL crashed every now and then. After a long search about MySQL, Micro Instance and Memory Managment I found out there is no default SWAP space for Micro instance. So if you want to avoid the crash you may need to setup a swap space for your micro instance. Actually performance wise is better to enable swap.
Steps below show how to make a swap space for your Micro instance. I assume you have AWS Account with a Micro instance running.
Run dd if=/dev/zero of=/swapfile bs=1M count=1024
Run mkswap /swapfile
Run swapon /swapfile
Add this line /swapfile swap swap defaults 0 0 to /etc/fstab
Step 4 is needed if you would like to automatically enable swap file after each reboot.
Some useful command related to SWAP space:
$ swapon -s
$ free -k
$ swapoff -a
$ swapon -a

How to stop mysqld

To find out the start command for mysqld (using a mac) I can do:
ps aux|grep mysql
I get the following output, which allows me to start mysql server.
/usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=...
How would I find the necessary command to stop mysql from the command line?
Try:
/usr/local/mysql/bin/mysqladmin -u root -p shutdown
Or:
sudo mysqld stop
Or:
sudo /usr/local/mysql/bin/mysqld stop
Or:
sudo mysql.server stop
If you install the Launchctl in OSX you can try:
MacPorts
sudo launchctl unload -w /Library/LaunchDaemons/org.macports.mysql.plist
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql.plist
Note: this is persistent after reboot.
Homebrew
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Binary installer
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart
I found that in: https://stackoverflow.com/a/102094/58768
There is an alternative way of just killing the daemon process by calling
kill -TERM PID
where PID is the value stored in the file mysqld.pid or the mysqld process id which can be obtained by issuing the command ps -a | grep mysqld.
I did it with next command:
sudo killall mysqld
I found the answer here.
Use
sudo stop mysql
For Windows, you can run this command directly if mysql/bin is in your path.
mysqladmin -u root -p shutdown
Worked for me on mac
a) Stop the process
sudo launchctl list | grep -i mysql
If the result shows anything like: "xxx.xxx.mysqlxxx"
sudo launchctl remove xxx.xxx.mysqlxxx
Example:
sudo launchctl remove org.macports.mysql56-server
b) Disable to autostart the process
sudo launchctl unload -wF /Library/LaunchDaemons/xxx.xxx.mysqlxxx.plist
Example:
sudo launchctl unload -wF /Library/LaunchDaemons/org.macports.mysql56-server.plist
Finally reboot your mac
Note: In some cases if you tried "a)" first, you need to reboot again before try b).
When mysql was installed with Homebrew, it automatically restarts when killed. You need to use the following command:
brew services stop mysql
PS: If you installed a specific version, it will be mysql#X.X
On OSX 10.8 and on, the control for MySQL is available from the System Configs. Open System Preferences, click on Mysql (usually on the very bottom) and start/stop the service from that pane. https://dev.mysql.com/doc/refman/5.6/en/osx-installation-launchd.html
The plist file is now under /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
for Binary installer use this:
to stop:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
to start:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
to restart:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart
Try killing mysqld four times in a row. It's the only thing that worked for me...
root#ubuntu:/etc/init# killall -KILL mysqld
root#ubuntu:/etc/init# killall -KILL mysqld
root#ubuntu:/etc/init# killall -KILL mysqld
root#ubuntu:/etc/init# killall -KILL mysqld
mysqld: no process found
Just keep killing it over and over until you see "mysqld: no process found".
Kill is definitly the wrong way! The PID will stay, Replicationsjobs will be killed etc. etc.
STOP MySQL Server
/sbin/service mysql stop
START MySQL Server
/sbin/service mysql start
RESTART MySQL Server
/sbin/service mysql restart
Perhaps sudo will be needed if you have not enough rights
What worked for me on CentOS 6.4 was running service mysqld stop as the root user.
I found my answer on nixCraft.
/etc/init.d/mysql stop
service mysql stop
killall -KILL mysql mysqld_safe mysqld
When you see the following information, you success
mysql: no process found
mysqld_safe: no process found
mysqld: no process found
I use this to solve the installation problem of MySQL 5.6 in Ubuntu 15.10 using this link.
During this installation, I encounter the problem saying:
"mysqld_safe A mysqld process already exists"
Just completely stop the mysqld, mysqld_safe, mysql solves the problem.
If my mysql keeps restarting
sudo rm -rf /usr/local/var/mysql/dev.work.err
mysql.server stop
worked for me.
To stop autostart of mysql on boot, the following worked for me with mysql 8.0.12 installed using Homebrew in macOS Mojave 10.14.1:
rm -rf ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
To stop MariaDB and MySQL server instance:
sudo mysqladmin shutdown
To start MariaDB and MySQL server instance:
mysqld &
To change data ownership for MariaDB and MySQL server instance:
sudo chown -R 755 /usr/local/mariadb/data
Just go to task manager.
Then in process, search mysqld.
right click on mysqld then click on stop.
with this process you can stop it without using commands.
first try this
sudo service apache2 stop
if not, then
sudo mysql stop
if not, then
sudo stop mysql
if not, then
sudo mysqladmin shutdown
I have been there, and I do with many tips, at the end of using tips that I follow will lead me to solved. So if you not solve in this issue, you just do other tips, till your issue get solved. Hopefully it's will help you. Thanks
For mysql 5.7 downloaded from binary file onto MacOS:
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
Following worked for me on my macbook pro:
brew services stop mysql
Incase if you want to stop all brew services:
brew services stop --all
if all else fails, this help me. Every time I tried to kill the process with the last installation it will respawn.
sudo rm -rf /usr/local/var/mysql
brew reinstall mysql
For MAMP
Stop servers (but you may notice MySQL stays on)
Remove or rename /Applications/MAMP/tmp/mysql/ which holds the mysql.pid and mysql.sock.lock files
When you go back to Mamp, you'll see MySQL is now off. You can "Start Servers" again.

Install MySQL in fedora

I am installing mysql and mysql-server in fedora.What I did was:
su (to change to root)
yum install mysql mysql-server
chkconfig --levels 235 mysqld on
and when I try to start mysqld using /etc/init.d/mysqld start, it gives me an error saying No such a file or directory.
By using whereis mysql I got the following result:
$whereis mysql
mysql: /usr/bin/mysql /usr/lib/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
Can some one help me find where I installed mysql and how I can start it? Thank you
Try starting MySQL by using service mysqld start instead.