logs – reinstall mysql at centos 6


shell> cp -r /var/lib/mysql /var/lib/mysql.bak
shell> rpm -qa | grep mysql
mysql-community-common-5.7.13-1.el6.x86_64
mysql-community-libs-compat-5.7.13-1.el6.x86_64
mysql57-community-release-el6-7.noarch
mysql-community-libs-5.7.13-1.el6.x86_64
php-mysqlnd-5.6.7-1.el6.remi.x86_64
shell> service mysqld stop
shell> yum remove mysql-client mysql-server mysql-common mysql-devel
shell> rm -rf /var/lib/mysql
shell> yum install mysql mysql-server
shell> grep 'temporary password' /var/log/mysqld.log
shell> mysql -u root -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
mysql> exit

# restore by sql file
shell> mysql -u root -p
Enter password:
mysql> CREATE DATABASE database_name;
mysql> exit
sheel> mysql -u username -p database_name < file.sql

# or using cold backup
shell> service mysqld stop
shell> mv /var/lib/mysql /var/lib/mysql.new
shell> mv /var/lib/mysql.bak /var/lib/mysql
shell> service mysqld start

Published by

G3n1k

just to remember what i had known :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s