安装

  1. # 先卸载mariadb
  2. rpm -qa | grep mariadb
  3. sudo rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
  4. # 检测系统是否自带安装mysql
  5. yum list installed | grep mysql
  6. # 如果发现有系统自带mysql
  7. yum -y remove mysql-libs.x86_64
  8. # 下载源文件(repo)
  9. wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
  10. # 安装(repo)
  11. sudo rpm -ivh mysql-community-release-el6-5.noarch.rpm
  12. # 安装mysql
  13. sudo yum install -y mysql-community-server && rm mysql-community-release-el6-5.noarch.rpm
  14. # 启动服务
  15. service mysqld start
  16. # 初始化设置
  17. mysql -u root
  18. use mysql;
  19. update user set password=PASSWORD("tianyunali") where User='root';
  20. grant all privileges on *.* to 'root'@'%' identified by 'tianyunali' with grant option;
  21. flush privileges;
  22. # 开机启动
  23. sudo chkconfig --add mysqld &&
  24. sudo chkconfig mysqld on
  25. mysql安全设置(必须!!!)
  26. mysql_secure_installation
  27. # 防火墙:
  28. #开放3306端口
  29. /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
  30. service iptables save

配置

内存会在100M以内

  1. sudo vim /etc/my.cnf
  2. innodb_buffer_pool_size=128M
  3. query_cache_size=16M
  4. tmp_table_size=64M
  5. key_buffer_size=32m
  6. performance_schema_max_table_instances=400
  7. table_definition_cache=400
  8. table_open_cache=256
  9. [client]
  10. default-character-set = utf8mb4
  11. [mysql]
  12. default-character-set = utf8mb4
  13. [mysqld]
  14. character-set-client-handshake = FALSE
  15. character-set-server = utf8mb4
  16. collation-server = utf8mb4_unicode_ci
  17. service mysqld restart

卸载

  1. # 先关闭服务
  2. systemctl stop mysqld
  3. # 关闭相关进程
  4. ps -ef |grep -i mysql
  5. # kill -9 pid
  6. # 删除自启动
  7. chkconfig --del mysqld
  8. yum remove mysql mysql-server mysql-libs mysql-server;
  9. rpm -qa|grep -i mysql | xargs yum -y remove
  10. rm -rf /usr/lib/mysql
  11. rm -rf /usr/share/mysql
  12. rm -rf /usr/my.cnf
  13. rm -rf /etc/my.cnf
  14. # 删除其他文件
  15. find / -name mysql