ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

Linux环境下部署MySQL8数据库

Linux环境下部署MySQL8数据库 MySQL安装1、下载软件包mysql-8.0.15-1.el7.x86_64.rpm-bundle.tar2、将软件包通过moba上传到linux系统/usr/local/soft/目录下3、解压软件包cd /usr/local/soft/ tar -xvf mysql-8.0.15-1.el7.x86_64.rpm-bundle.tar4、卸载系统自带mariadbrpm -qa | grep mariadb yum -y remove mariadb-libs-5.5.52-1.el7.x86_645、下载依赖包可直接全部复制粘贴批量执行yum -y install openssl-devel perl-JSON yum install -y libaio.x86_64 libaio-devel.x86_64 yum install -y openssl-devel.x86_64 openssl.x86_64 yum install -y perl.x86_64 perl-devel.x86_64 yum install -y perl-JSON.noarch yum install -y autoconf yum install net-tools –y yum -y install numactl6、顺序安装mysql可直接全部复制粘贴批量执行rpm -ivh mysql-community-common-8.0.15-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-8.0.15-1.el7.x86_64.rpm rpm -ivh mysql-community-client-8.0.15-1.el7.x86_64.rpm rpm -ivh mysql-community-server-8.0.15-1.el7.x86_64.rpm rpm -ivh mysql-community-devel-8.0.15-1.el7.x86_64.rpm安装完默认是mysql用户、用户组和权限chown -R mysql:mysql /var/lib/mysql/7、重启mysql服务systemctl restart mysqld.service systemctl status mysqld.service若启动失败查看tail -n 100 /var/log/mysqld.log8、查看密码cat /var/log/mysqld.log | grep password或cd /var/log/ cat mysqld.log9、数据库登陆mysql -u root -p输入第八步中的密码进行登陆10、设置登陆密码复杂度set global validate_password.length4; set global validate_password.policy0;11、修改密码ALTER USER rootlocalhost IDENTIFIED BY root123; flush privileges;12、开放所有IP都能访问use mysql; select host, user, authentication_string, plugin from user; CREATE USER root% IDENTIFIED BY root123; grant all privileges ON *.* to root% with grant option; flush privileges;13、修改加密方式ALTER USER root% IDENTIFIED WITH mysql_native_password BY root123; select host, user, authentication_string, plugin from user;14、重启数据库quit systemctl restart mysqld.service或systemctl start mysqld设置开机自启动systemctl enable mysqld.service15、远程navicat连接测试16、其它配置初始状态# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html [mysqld] # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size 128M # # Remove the leading # to disable binary logging # Binary logging captures changes between backups and is enabled by # default. Its default setting is log_binbinlog # disable_log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size 128M # sort_buffer_size 2M # read_rnd_buffer_size 2M # # Remove leading # to revert to previous value for default_authentication_plugin, # this will increase compatibility with older clients. For background, see: # https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin # default-authentication-pluginmysql_native_password datadir/var/lib/mysql socket/var/lib/mysql/mysql.sock log-error/var/log/mysqld.log pid-file/var/run/mysqld/mysqld.pid其它配置参考如下vi /etc/my.cnf# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html [mysqld] port3323 #skip-grant-tables # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size 128M # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size 128M # sort_buffer_size 2M # read_rnd_buffer_size 2M datadir/var/lib/mysql socket/var/lib/mysql/mysql.sock log-error/var/log/mysqld.log pid-file/var/run/mysqld/mysqld.pid # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links0 lower_case_table_names1 sql_modeSTRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION max_allowed_packet 500M wait_timeout86400重置密码ALTER USER rootlocalhost IDENTIFIED BY asdfadfbEVG; ALTER USER root% IDENTIFIED BY asdfadfbEVG; flush privileges;FAQ1、错误依赖检测失败libcrypto.so.10()(64bit) 被 mysql-community-libs-8.0.15-1.el7.x86_64 需要遇到类似的错误的话可以试试在rpm安装命令后添加--nodeps --force如rpm -ivh mysql-community-common-8.0.15-1.el7.x86_64.rpm --nodeps --force rpm -ivh mysql-community-libs-8.0.15-1.el7.x86_64.rpm --nodeps --force rpm -ivh mysql-community-client-8.0.15-1.el7.x86_64.rpm --nodeps --force rpm -ivh mysql-community-server-8.0.15-1.el7.x86_64.rpm --nodeps --force rpm -ivh mysql-community-devel-8.0.15-1.el7.x86_64.rpm --nodeps --force2、云服务器上数据库总是恢复可在配置文件中添加innodb_force_recovery 13、让表忽略大小写由于8.0没法设置参数后重启失败所以必须删掉老库重新启动才行。切记本步骤要删掉老库所有资料如果是数据库当前有用请做好备份再进行操作。systemctl stop mysqld #默认数据在这里 cd /var/lib/mysql rm -rf *编辑配置文件vim /etc/my.cnf配置文件中添加symbolic-links0 lower_case_table_names1 sql_modeSTRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION max_allowed_packet 500M wait_timeout86400重启数据库systemctl restart mysqld此时由于重新初始化数据库老密码已经没有了系统自动初始化一个随机新密码sudo grep temporary password /var/log/mysqld.log还有一种就是最新版的MYSQL8 默认root没密码 直接mysql进去重复上面10-13步骤然后验证配置结果show variables like %case_table%;重新远程连接如下参考地址Mysql8忽略大小写的解决方案.240105 - 中国的Amadeus - 博客园
返回列表