首页 > 数据库 >【MySQL】在CentOS 7.5平台通过YUM安装MySQL 5.7

【MySQL】在CentOS 7.5平台通过YUM安装MySQL 5.7

时间:2023-04-12 10:16:12浏览次数:47  
标签:node01 lib CentOS 5.7 MySQL mysqld usr mysql root

[root@node01 ~]# cat >> /etc/hosts <<EOF
192.168.1.201   node01
EOF

[root@node01 ~]# useradd mysql
[root@node01 ~]# id mysql
uid=500(mysql) gid=500(mysql) groups=500(mysql)

[root@node01 ~]# cat >> /etc/security/limits.conf <<EOF
mysql            soft    nproc          4096
mysql            hard    nproc          65535
mysql            soft    nofile         4096
mysql            hard    nofile         65535
EOF

[root@node01 ~]# yum install -y libaio yum-utils
[root@node01 ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm
[root@node01 ~]# yum-config-manager --disable mysql80-community
[root@node01 ~]# yum-config-manager --enable mysql57-community

[root@node01 ~]# yum repolist all | grep mysql 
[root@node01 ~]# yum install -y mysql-community-server
[root@node01 ~]# yum install -y mysql-community-devel
[root@node01 ~]# vim /usr/lib/systemd/system/mysqld.service
# Sets open_files_limit
LimitNOFILE = 65535

[root@node01 ~]# vim /etc/my.cnf
[mysqld]
user = mysql
port = 3306
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error = mysqld_error.log
pid-file=mysqld.pid
log_timestamps = SYSTEM
character-set-server = utf8mb4

open-files-limit = 65535

max_connections = 500
max_connect_errors = 10000

max_allowed_packet = 32M

tmp_table_size = 512M
max_heap_table_size = 512M

slow_query_log = 1
long_query_time = 5
slow_query_log_file = mysqld_slow.log

server_id = 201
log_bin = mysql-bin
binlog_cache_size = 16M
max_binlog_cache_size = 4G
max_binlog_size = 128M
expire_logs_days = 7
binlog_rows_query_log_events = on
log_slave_updates = on

master_info_repository = table
relay_log_info_repository = table
relay_log = relay-bin
relay_log_recovery = 1

transaction-isolation = READ-COMMITTED
innodb_buffer_pool_size = 8G
innodb_buffer_pool_instances = 8
innodb_log_file_size = 256M
innodb_log_files_in_group = 4
innodb_log_buffer_size = 16M
innodb_undo_logs = 128
innodb_undo_tablespaces = 3
innodb_undo_log_truncate = 1
innodb_data_file_path = ibdata1:1024M:autoextend
innodb_temp_data_file_path = ibtmp1:128M:autoextend
innodb_print_all_deadlocks = 1 

[mysql]
default-character-set = utf8mb4

[root@node01 ~]# mysqld --initialize-insecure
[root@node01 ~]# systemctl daemon-reload
[root@node01 ~]# systemctl start mysqld.service
[root@node01 ~]# systemctl status mysqld.service
[root@node01 ~]# netstat -tunlp | grep mysqld
tcp6       0      0 :::3306                 :::*                    LISTEN      22255/mysqld

[root@node01 ~]# mysql_secure_installation
##密码校验插件
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: n

##修改root密码
Please set the password for root here.
New password: 
Re-enter new password: 

##删除匿名用户
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

##禁止root远程登录
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

##删除测试库
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.
 - Removing privileges on test database...
Success.

##刷新权限
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done! 

[root@node01 ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 231
Server version: 5.7.32-log MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select version();
+------------+
| version()  |
+------------+
| 5.7.32-log |
+------------+
1 row in set (0.00 sec)

mysql> create user 'root'@'%' identified by 'abcd.1234';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> flush PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> show grants for 'root'@'%';
+-------------------------------------------------------------+
| Grants for root@%                                           |
+-------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION |
+-------------------------------------------------------------+
1 row in set (0.00 sec)
MySQL 5.7通过Tcmalloc管理内存
[root@node01 ~]# yum -y install gcc make gcc-c++ lsof libunwind libunwind-devel
[root@node01 ~]# wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.10/gperftools-2.10.tar.gz
[root@node01 ~]# tar zxvf gperftools-2.10.tar.gz 
[root@node01 ~]# cd gperftools-2.10

[root@node01 gperftools-2.10]# ./configure
[root@node01 gperftools-2.10]# make
[root@node01 gperftools-2.10]# make install

[root@node01 ~]# cat /usr/lib/systemd/system/mysqld.service
# Use this to switch malloc implementation
EnvironmentFile=-/etc/sysconfig/mysql

[root@node01 ~]# echo 'LD_PRELOAD=/usr/local/lib/libtcmalloc.so' > /etc/sysconfig/mysql  

[root@node01 ~]# systemctl daemon-reload 
[root@node01 ~]# systemctl restart mysqld

[root@node01 ~]# lsof -n | grep tcmalloc
mysqld    17206               mysql  mem       REG                8,3    2644880    4501918 /usr/local/lib/libtcmalloc.so.4.5.10
mysqld    17206 17207         mysql  mem       REG                8,3    2644880    4501918 /usr/local/lib/libtcmalloc.so.4.5.10
mysqld    17206 17208         mysql  mem       REG                8,3    2644880    4501918 /usr/local/lib/libtcmalloc.so.4.5.10
mysqld    17206 17209         mysql  mem       REG                8,3    2644880    4501918 /usr/local/lib/libtcmalloc.so.4.5.10
mysqld    17206 17210         mysql  mem       REG                8,3    2644880    4501918 /usr/local/lib/libtcmalloc.so.4.5.10
mysqld    17206 17211         mysql  mem       REG                8,3    2644880    4501918 /usr/local/lib/libtcmalloc.so.4.5.10
mysqld    17206 17212         mysql  mem       REG                8,3    2644880    4501918 /usr/local/lib/libtcmalloc.so.4.5.10
mysqld    17206 17213         mysql  mem       REG                8,3    2644880    4501918 /usr/local/lib/libtcmalloc.so.4.5.10
mysqld    17206 17214         mysql  mem       REG                8,3    2644880    4501918 /usr/local/lib/libtcmalloc.so.4.5.10
MySQL 5.7通过Jemalloc管理内存
[root@node01 ~]# wget https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2
[root@node01 ~]# tar -jxvf jemalloc-5.2.1.tar.bz2 
[root@node01 ~]# cd jemalloc-5.2.1

[root@node01 jemalloc-5.2.1]# ./configure
[root@node01 jemalloc-5.2.1]# make
[root@node01 jemalloc-5.2.1]# make install

[root@node01 ~]# cat /usr/lib/systemd/system/mysqld.service
# Use this to switch malloc implementation
EnvironmentFile=-/etc/sysconfig/mysql

[root@node01 ~]# echo 'LD_PRELOAD=/usr/local/lib/libjemalloc.so' > /etc/sysconfig/mysql   

[root@node01 ~]# systemctl daemon-reload 
[root@node01 ~]# systemctl restart mysqld

[root@node01 ~]# lsof -n | grep jemalloc
mysqld     6272         mysql  mem       REG              253,0    4397600  273167915 /usr/local/lib/libjemalloc.so.2
mysqld     6272  6273   mysql  mem       REG              253,0    4397600  273167915 /usr/local/lib/libjemalloc.so.2
mysqld     6272  6274   mysql  mem       REG              253,0    4397600  273167915 /usr/local/lib/libjemalloc.so.2

 

标签:node01,lib,CentOS,5.7,MySQL,mysqld,usr,mysql,root
From: https://www.cnblogs.com/dbprofessional/p/17308811.html

相关文章

  • CentOS 本地镜像源替换为阿里云镜像源
     本文为joshua317原创文章,转载请注明:转载自joshua317博客 https://www.joshua317.com/article/294简介CentOS,是基于RedHatLinux提供的可自由使用源代码的企业级Linux发行版本;是一个稳定,可预测,可管理和可复制的免费企业级计算平台。下载地址: https://mirrors.aliyun.......
  • 【CentOS7】history命令
    修改~/.bashrc,增加历史行数HISTSIZE=5000HISTCONTROL=ignorespaceignoredups   默认,忽略重复命令ignorespace   忽略所有以空格开头的命令ignoreboth   ignoredups和ignorespace的组合erasedups   删除历史记录中重复命令,相同的指令仅保留最近的一个......
  • MySQL查询结果条数编号示例 mysql 查找结果中自动加序号列
    SELECT@row:=@row+1asrow,t.idFROMsgcorp_productt,(SELECT@row:=0)rwheret.idnotin(selectproduct_idfromsgcorp_pic)http://database.51cto.com/art/201011/235142.htm......
  • 如何查看Linux发行版本是Ubuntu还是CentOS
     https://askubuntu.com/questions/459402/how-to-know-if-the-running-platform-is-ubuntu-or-centos-with-help-of-a-bash-scri HowtoknowiftherunningplatformisUbuntuorCentOSwithhelpofaBashscript? OS_NAME=$(lsb_release-si)case"$OS_N......
  • 力扣1112(MySQL)-每位学生的最高成绩(中等)
    题目:表:Enrollments(student_id,course_id)是该表的主键。问题编写一个SQL查询,查询每位学生获得的最高成绩和它所对应的科目,若科目成绩并列,取course_id最小的一门。查询结果需按student_id增序进行排序。示例Enrollments表:Result表: 建表语句:1CreatetableIf......
  • mysql安装和nodejs连接数据库
      mysql下载地址https://dev.mysql.com/downloads/installer/        第一步,安装自定义   2.添加这三个产品   3.下一步   4.默认端口3306,如果被占用了就自己改下    5.强密码认证   6,添加密码和用户,密码......
  • PHP连接MYSQL数据库参数设置机器增删查改操作
     1.param.php <?phpsession_start();if(!$_SESSION["user"]->poststuno)exit('你的工号不正确');if($_SESSION["user"]->juese=='001')exit('未知错误,请联系管理员0001');$db_host_main="192.168.*.*";//主数......
  • MySQL行级锁初探
     MySQL行级锁初探 版本:8.0.29最近研究MySQL行级锁发现一个有趣的东东。正常情况下,对于表级锁来说,对于会话持有某个表的锁(无论什么类型),可以在performance_schema.metadata_locks中查到会话持有锁的信息。而对于会话对表的DML操作涉及的每一行,竟然都能在数据字典performance......
  • linux CentOS 7上安装Chrome浏览器
    目录linuxCentOS7上安装Chrome浏览器添加Chrome浏览器的官方存储库,使用以下命令:安装Chrome浏览器:确认Chrome浏览器是否安装成功:linuxCentOS7上安装Chrome浏览器在CentOS7上安装Chrome浏览器可以按照以下步骤操作:添加Chrome浏览器的官方存储库,使用以下命令:$sudotee/etc......
  • 安装mysql
    在服务器下执行cd/usr/local,进入到local文件中。执行mkdirmysql创建文件夹。 mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar文件拷贝到b服务器的/usr/local/mysql目录下。在b服务器cd/usr/local/mysql进入mysql文件夹,执行tar-xvfmysql-8.0.22-1.el7.x86_64.rpm-bundle.tar。......