apt-get install -y mysql-server-5.6
service mysql stop
cp -a /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
sed -i 's|3306|3307|g' /etc/mysql/my.cnf
sed -i 's|/var/log/mysql|/data/mysql/log|g' /etc/mysql/my.cnf
sed -i 's|/var/lib/mysql|/data/mysql/data|g' /etc/mysql/my.cnf
sed -i 's|bind-address|#bind-address|g' /etc/mysql/my.cnf
sed -i 's|/var/log/mysql|/data/mysql/log|g' /etc/apparmor.d/usr.sbin.mysqld
sed -i 's|/var/lib/mysql|/data/mysql/data|g' /etc/apparmor.d/usr.sbin.mysqld
[mysqld]
slow-query-log-file = /data/mysql/log/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes
mkdir -p /data/mysql/log
mkdir -p /data/mysql/data
cp -av /var/lib/mysql/* /data/mysql/data
chown -R mysql:mysql /data/mysql
service apparmor restart
service mysql restart
ps -ef|grep mysql
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';FLUSH PRIVILEGES;"
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456';FLUSH PRIVILEGES;"
mysql -uroot -p123456 -e "delete from mysql.user where host != '%' and host != 'localhost';"
apt-get autoclean
apt-get clean
apt-get autoremove
彻底卸载mysql
rm -rf /var/lib/mysql/
rm -rf /etc/mysql/
apt-get autoremove --purge mysql-server-5.6
apt-get remove mysql-server
apt-get autoremove mysql-server
apt-get remove mysql-common
dpkg -l |grep ^rc|awk '{print $2}'|xargs dpkg -P