安装
# 先卸载mariadb
rpm -qa | grep mariadb
sudo rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
# 检测系统是否自带安装mysql
yum list installed | grep mysql
# 如果发现有系统自带mysql
yum -y remove mysql-libs.x86_64
# 下载源文件(repo)
wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
# 安装(repo)
sudo rpm -ivh mysql-community-release-el6-5.noarch.rpm
# 安装mysql
sudo yum install -y mysql-community-server && rm mysql-community-release-el6-5.noarch.rpm
# 启动服务
service mysqld start
# 初始化设置
mysql -u root
use mysql;
update user set password=PASSWORD("tianyunali") where User='root';
grant all privileges on *.* to 'root'@'%' identified by 'tianyunali' with grant option;
flush privileges;
# 开机启动
sudo chkconfig --add mysqld &&
sudo chkconfig mysqld on
mysql安全设置(必须!!!)
mysql_secure_installation
# 防火墙:
#开放3306端口
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
service iptables save
配置
内存会在100M以内
sudo vim /etc/my.cnf
innodb_buffer_pool_size=128M
query_cache_size=16M
tmp_table_size=64M
key_buffer_size=32m
performance_schema_max_table_instances=400
table_definition_cache=400
table_open_cache=256
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
service mysqld restart
卸载
# 先关闭服务
systemctl stop mysqld
# 关闭相关进程
ps -ef |grep -i mysql
# kill -9 pid
# 删除自启动
chkconfig --del mysqld
yum remove mysql mysql-server mysql-libs mysql-server;
rpm -qa|grep -i mysql | xargs yum -y remove
rm -rf /usr/lib/mysql
rm -rf /usr/share/mysql
rm -rf /usr/my.cnf
rm -rf /etc/my.cnf
# 删除其他文件
find / -name mysql