mysql8.0更改lower_case_table_names

mysql8.0更改lower_case_table_names

mysql8.0安装初始化之后是不能更改lower_case_table_names的
下面是官方文档的一段话:
In MySQL 8.0, the lower_case_table_names variable can only be configured when the MySQL server is initialized.

解决方法:
方法一:在初始化的时候就要设置好这个变量的值
方法二:删除数据目录,重新初始化
(1)删除数据目录datadir=/usr/local/mysql/data
rm -rf /usr/local/mysql/data
(2)在配置文件中[mysqld]下添加lower_case_table_names = 1
```
vim /etc/my.cnf

[mysqld]
basedir=/usr/local/mysql # 基本路径
datadir=/usr/local/mysql/data #数据路径 (先在/usr/local/mysql建data目录)
socket=/usr/local/mysql/data/mysql.sock # socket文件
symbolic-links=0
log-error=/usr/local/mysql/data/mysqld.log #错误日志
pid-file=/usr/local/mysql/data/mysqld.pid #pid文件
**lower_case_table_names = 1** **#添加这行**

[mysql]
socket=/usr/local/mysql/data/mysql.sock
[mysqldump]
socket=/usr/local/mysql/data/mysql.sock

```
(3)执行初始化命令
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --lower-case-table-names=1

(4)检查变量的值
跳过授权表启动
```
mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables &
```
免密登录
```
mysql -uroot -p 不需要输入密码直接回车

show variables like '%lower_case_table_names%';
```
修改密码等操作,请参考
[https://blog.csdn.net/qq_41788609/article/details/108390186](https://blog.csdn.net/qq_41788609/article/details/108390186)

posted @ 2020-09-10 18:16  小明大强  阅读(5718)  评论(0编辑  收藏  举报