首页 > 数据库 >【MySQL 8.0】在 CentOS 7.5 安装 MySQL 8.0

【MySQL 8.0】在 CentOS 7.5 安装 MySQL 8.0

时间:2023-08-25 10:02:59浏览次数:53  
标签:8.0 node01 log local 7.5 usr mysql MySQL root

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

[root@node01 ~]# useradd mysql

[root@node01~]# echo mysql | passwd --stdin mysql 
Changing password for user mysql.
passwd: all authentication tokens updated successfully.

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

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

[root@node01 ~]# cat /sys/block/sda/queue/scheduler 
noop [deadline] cfq 

[root@node01 ~]# echo "vm.swappiness = 10" >>/etc/sysctl.conf 
[root@node01 ~]# echo 'vm.dirty_background_ratio = 5' >>/etc/sysctl.conf 
[root@node01 ~]# echo 'vm.dirty_ratio = 10' >>/etc/sysctl.conf
[root@node01 ~]# sysctl -p 

[root@node01 ~]# yum install -y libaio

[root@node01 ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz
[root@node01 ~]# tar xvf mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz

[root@node01 ~]# mv mysql-8.0.32-linux-glibc2.12-x86_64 mysql
[root@node01 ~]# mv mysql /usr/local/
[root@node01 ~]# mkdir /usr/local/mysql/data
[root@node01 ~]# chown -R mysql:mysql /usr/local/mysql
[root@node01 ~]# mkdir /var/lib/mysql
[root@node01 ~]# chown -R mysql:mysql /var/lib/mysql
[root@node01 ~]# mkdir /var/lib/mysql-files
[root@node01 ~]# chown mysql:mysql /var/lib/mysql-files
[root@node01 ~]# chmod 700 /var/lib/mysql-files

[root@node01 ~]# echo 'export PATH=$PATH:/usr/local/mysql/bin'>>/etc/profile
[root@node01 ~]# source /etc/profile
[root@node01 ~]# env | grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin

[root@node01 ~]# vim /etc/my.cnf
[mysqld]
user = mysql
port = 3306
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/var/lib/mysql/mysql.sock
secure_file_priv = /var/lib/mysql-files
pid-file=mysqld.pid

character_set_server=utf8mb4
transaction_isolation=REPEATABLE-READ
default_time_zone = "+8:00"
default_authentication_plugin=caching_sha2_password
default_storage_engine=InnoDB

max_connections=500
max_connect_errors=10000

wait_timeout=28800
interactive_timeout=28800

open_files_limit=65535

max_allowed_packet=64M

tmp_table_size=512M
max_heap_table_size=512M

log-error = mysqld_error.log
slow_query_log=on
slow_query_log_file=mysqld_slow.log
long_query_time=2
log_timestamps = SYSTEM
log_output = FILE,TABLE

server_id=101
log_bin=mysql-bin
binlog_format = row
binlog_cache_size=16M
binlog_row_image = full
binlog_expire_logs_seconds=2592000
binlog_rows_query_log_events=on
max_binlog_size=128M
sync_binlog = 1

relay_log = relay-bin
relay_log_recovery=on

innodb_buffer_pool_size=8GB
innodb_buffer_pool_instances=8
innodb_redo_log_capacity=2GB
innodb_log_buffer_size=16M
innodb_max_undo_log_size=1GB
innodb_undo_log_truncate=on
innodb_data_file_path=ibdata1:1024M:autoextend
innodb_temp_data_file_path=ibtmp1:128M:autoextend

[mysql]
socket=/var/lib/mysql/mysql.sock
prompt=(\\u@\\h) >\\_
                         
[root@node01 ~]# chown mysql:mysql /etc/my.cnf

[root@node01 ~]# mysqld --initialize

[root@node01 ~]# cat /usr/local/mysql/data/mysqld_error.log | grep password
2023-05-30T13:34:58.339962+08:00 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: =frL7)R.MYzk

[root@node01 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/

[root@node01 ~]# /etc/init.d/mysql.server start
[root@node01 ~]# /etc/init.d/mysql.server status

[root@node01 ~]# echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
[root@node01 ~]# ldconfig

[root@node01 ~]# ln -s /usr/local/mysql/include/ /usr/include/mysql
[root@node01 ~]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

[root@node01 ~]# mysql_secure_installation --no-defaults
Securing the MySQL server deployment.
Enter password for user root: 
The existing password for the user account root has expired. Please set a new password.
New password: 
Re-enter new password: 

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: 

Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : 

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

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 -pabcd.1234
(root@localhost) > select version(); 
+-----------+
| version() |
+-----------+
| 8.0.32    |
+-----------+
1 row in set (0.00 sec)

(root@localhost) > create user 'root'@'%' identified with caching_sha2_password by 'abcd.1234'; 
Query OK, 0 rows affected (0.02 sec)

(root@localhost) > grant all privileges on *.* to 'root'@'%' with grant option; 
Query OK, 0 rows affected (0.02 sec)

(root@localhost) > flush privileges; 
Query OK, 0 rows affected (0.04 sec)

[root@node01 ~]# mysql -uroot -pabcd.1234 -hnode01
(root@node01) > show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

标签:8.0,node01,log,local,7.5,usr,mysql,MySQL,root
From: https://blog.51cto.com/dbprofessional/7226460

相关文章

  • CentOS7.9搭建开发环境(Java、MySQL、Nginx、Redis)
    系统使用的阿里云CentOS7.964位SCC版。先安装个文件上传下载工具lrzsz,xshell登录终端,运行下面的命令:yuminstall-ylszrz 这是因为yum源的问题,需要修改yum配置。执行以下命令:cd/etc/yum.repos.dmvCentOS-Base.repoCentOS-Base.repo.backupwgethttp://mirrors.......
  • 手把手教你Linux CentOS 8 安装MySQL 8
     安装步骤我所使用的Linux版本是CentOS8,在CentOS8上安装MySQL的步骤:启用MySQL8.0存储库首先,您需要启用MySQL8.0存储库。为此,请下载和安装MySQL的存储库包:sudodnfinstallhttps://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm安装MyS......
  • mysql索引的详解和慢查询优化
    什么是索引?索引是一种特殊的数据结构,由数据表中的一列或多列组合而成 建立索引的目的是什么?索引的目的在于提高查询效率,可以类比字典,如果要查“mysql”这个单词,我们肯定需要定位到m字母,然后从下往下找到y字母,再找到剩下的sql。如果没有索引,那么你可能需要把所有单词看一遍才......
  • destoon8.0自媒体类型综合资讯门户模板
     随着时代发展,自媒体资讯适合当前的互联网情形。呕心沥血开发的一套自媒体综合门户网站模板,本模板采用纯手写开发,带会员中心。首页,列表页,内容页,搜索页面精心编写,非常大气,并配移动端。注意:模板目前只用了资讯模块,会员模块,其他模块都禁用了。特色:1、非常适合做资讯门户站。2、首页,......
  • ubuntu18.04安装g2o
    先对g2o的依赖库进行安装:sudoapt-getupdatesudoapt-getinstalllibeigen3-devsudoapt-getinstalllibsuitesparse-devsudoapt-getinstallqtdeclarative5-devsudoapt-getinstallqt5-qmakesudoapt-getinstalllibqglviewer-dev-qt5然后下载g2o(2020那个版本)......
  • 关于安装Ambari 2.7.5 + HDP3.1.5
    参考文档安装Ambari2.7.5+HDP3.1.5(附安装包)_ambari安装包下载_不饿同学的博客-CSDN博客关于第11点,在浏览器输入http://hostname显示不了,要使用该hostname-ip才可以显示关于14,没找到maven-3.8.2而是使用了maven-3.8.8关于安装Ambari&HDP的配置libtirpc-devel本地源,该libtirpc......
  • MySQL基础笔记
    MySQLDDL:操作数据库和表DML:对数据进行增删改DQL:对数据进行查询DCL:对数据库进行权限管理数据库增删改查createdatabaseifnotexistsdb1;#如果数据库不存在才创建dropdatabaseifexistsdb1;#如果数据库存在才删除usedb1;#使用数据库selectDATABASE();#......
  • 不同系统无法安装mysqlclient的解决办法
    (注意系统的版本和MySQLclient的版本,Python版本的对应问题)一CentOS(红帽)#CentOS有Python、Mysql的开发工具包,安装后使用pip安装mysqlclient即可yuminstallmysql-develyuminstallpython-devel#yuminstallpython36-develpipinstallmysqlclient二Ubuntu#Ubuntu的话,......
  • MySQL 索引提示 - FORCE INDEX
    概述 在MySQL中,FORCEINDEX是一种查询提示,用于强制查询优化器使用特定索引来执行查询。查询优化器在执行查询时,会根据统计信息和查询条件等来选择最优的执行计划,包括选择哪个索引来提高查询性能。但有时候查询优化器可能会选择非最优的索引,或者无法识别最适合的索引,这时可以使......
  • mysql导入sql文件“Index column size too large. The maximum column size is 767 by
    问题分析由于MySQL的InnoDB引擎表索引字段长度的限制为767字节,因此对于多字节字符集的大字段或者多字段组合,创建索引时会出现该问题。说明注:以utf8mb4字符集字符串类型字段为例。utf8mb4是4字节字符集,默认支持的索引字段最大长度是191字符(767字节/4字节每字符......