centos 修改mysql5.7表名区分大小写
时间: 2023-09-20 16:14:42 浏览: 134
在CentOS上,要修改MySQL 5.7的表名区分大小写的设置,可以按照以下步骤进行操作:
1. 打开终端或SSH连接到CentOS服务器。
2. 使用root用户或具有sudo权限的用户登录。
3. 编辑MySQL的配置文件my.cnf。在CentOS 7和CentOS 8上,my.cnf文件通常位于`/etc/my.cnf`或`/etc/mysql/my.cnf`。
```
sudo vi /etc/my.cnf
```
或者
```
sudo nano /etc/my.cnf
```
4. 在配置文件中,找到[mysqld]部分,并在其下方添加以下行:
```
lower_case_table_names=2
```
设置lower_case_table_names参数为2表示表名区分大小写。
如果要将表名视为不区分大小写,请将lower_case_table_names参数设置为1。
5. 保存并关闭文件。
在vi编辑器中,按下Esc键,然后输入`:wq`保存并退出。
在nano编辑器中,按下Ctrl+X,然后按下Y确认保存,并按下Enter键退出。
6. 重启MySQL服务以使更改生效。
```
sudo systemctl restart mysqld
```
请注意,修改MySQL的表名区分大小写设置可能会影响现有数据库和表的查询和操作。在进行此更改之前,请确保了解潜在的影响并进行适当的备份。
相关问题
帮我写一个mysql5.7版本的centos7上的安装sehll脚本,要求大小写不敏感,sehll的开头可以自己指定安装的目录和具体版本
好的,我可以为您编写安装mysql5.7版本的centos7的sehll脚本。以下是我为您准备的脚本:
```#!/bin/sh
# MySQL installation script for CentOS 7
# Set the installation directory and version number
INSTALL_DIR=/usr/local/mysql
VERSION=5.7.31
# Download the MySQL repository configuration package
yum -y install wget
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
# Install the MySQL repository configuration package
yum -y localinstall mysql57-community-release-el7-11.noarch.rpm
# Install the MySQL server and client packages
yum -y install mysql-community-server
yum -y install mysql-community-client
# Start the MySQL server and enable it to start automatically on boot
systemctl start mysqld
systemctl enable mysqld
# Set the MySQL root user password
temp_password=$(grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}')
mysql --connect-expired-password -uroot -p"$temp_password" -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourNewPasswordHere';FLUSH PRIVILEGES;"
# Set the MySQL configuration file to be case insensitive
echo "lower_case_table_names = 1" >> /etc/my.cnf
# Restart the MySQL server to apply the configuration changes
systemctl restart mysqld
```
请注意,这个脚本将下载并安装mysql5.7版本,然后启动mysql服务并且设置mysql root用户的密码。此外,该脚本将配置mysql以使其大小写不敏感。请提前设置好您的新密码并将“YourNewPasswordHere”替换成您的新密码。如有需要,您可以根据实际情况更改安装目录和版本号。
阅读全文
相关推荐














