当前位置:网站首页>[MySQL 11] how to solve the case sensitive problem of MySQL 8.0.18
[MySQL 11] how to solve the case sensitive problem of MySQL 8.0.18
2022-07-03 07:43:00 【Rusty well began】
1、 Check the status
adopt show variables Command to view the current mysql Whether it is case sensitive , as follows :
mysql Two parameters related to case sensitive configuration ,lower_case_file_system and lower_case_table_names.
View the current mysql Case sensitive configuration for
show global variables like '%lower_case%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_file_system | ON |
| lower_case_table_names | 0 |
+------------------------+-------+
lower_case_table_names=1 Express mysql It's case insensitive
lower_case_table_names=0 Express mysql It's case sensitive
2、 Modify the configuration
MySQL 8.0 Above version , Case sensitive configuration comparison pit , According to the official documents, the following information can be found :
lower_case_table_names can only be configured when initializing the server.
Changing the lower_case_table_names setting after the server is initialized is prohibited.
lower_case_table_names Can only be configured when initializing the server . Prohibit changes after server initialization lower_case_table_names Set up .
lower_case_table_names The configuration must be installed MySQL after , initialization mysql Valid only when configured . once mysql After starting , Reset is invalid , And startup error .
Reinitialization required MySQL database , And during initialization , Before initialization lower_case_table_names = 1 Write to my.cnf In file
3、 Reinitialize MySQL database
3.1、 Out of Service
Before modifying the configuration , Please put mysql Service stopped . Execute the following command :
systemctl stop mysqld.service
3.2、 Delete error log
For easy viewing mysql Error log for , You can put /var/log/mysqld.log Delete . The order is as follows :
rm /var/log/mysqld.log
3.3、 Delete the system database and user database
take mysql The system database and user database in the database are deleted , Execute the following command :
(1) see /var/lib/mysql Below the table of contents
[[email protected] mysql]# ls
auto.cnf binlog.000003 binlog.000006 binlog.000009 ca.pem ib_buffer_pool ib_logfile1 mysql phoenix server-cert.pem undo_001
binlog.000001 binlog.000004 binlog.000007 binlog.index client-cert.pem ibdata1 ib_logfile2 mysql.ibd private_key.pem server-key.pem undo_002
binlog.000002 binlog.000005 binlog.000008 ca-key.pem client-key.pem ib_logfile0 #innodb_temp performance_schema public_key.pem sys

(2) Recursive delete /var/lib/mysql Below the table of contents
[[email protected] mysql]# rm -rf *
3.4、 Create database directory
Above will be the existing database directory /var/lib/mysql Delete , Next, you will manually create an empty directory and authorize . The order is as follows :
(1) Manually create a mysql Catalog , That is, the one just deleted above mysql Catalog
[[email protected] lib]# mkdir mysql
[[email protected] lib]# ls
alternatives dbus games logrotate misc mysql-files NetworkManager plymouth postfix rpm-state stateless tuned yum
authconfig dhclient initramfs machines mysql mysql-keyring os-prober polkit-1 rpm rsyslog systemd vmware
(2) by /var/lib/mysql Directory authorization , Set the user and group of the directory
[[email protected] lib]# chown -R mysql:mysql mysql
(3) View catalog details , Authorized success
[[email protected] lib]# ll|grep mysql
drwxr-xr-x. 2 mysql mysql 6 Jul 1 17:01 mysql
drwxr-x---. 2 mysql mysql 6 Sep 20 2019 mysql-files
drwxr-x---. 2 mysql mysql 6 Sep 20 2019 mysql-keyring
3.5、 To configure lower_case_table_names
Use vim Editor Editor /etc/my.cnf file , as follows :
[[email protected] lib]# vim /etc/my.cnf
Add lower_case_table_names To configure , The configuration is as follows :
# Whether the sql Sentence case sensitive ,1 Indicates insensitivity
lower_case_table_names = 1
Save configuration information .
3.6、 initialization MySql
Execute the following command initialization mysql database :
[[email protected] /]# mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql --basedir=/var/lib/mysql --datadir=/var/lib/mysql
Tips: Be careful my.cnf Is the file path correct
3.7、 start-up MySql service
systemctl start mysqld.service
4、 Sign in MySql
Because the above implementation MySql Initialization operation , The old password is no longer usable .MySQL A temporary password will be created during initialization , Temporary passwords are stored in /var/log/mysql/error.log in .
(1) Find temporary password
Use cat and grep Command matching search , The order is as follows :
cat /var/log/mysql/mysqld.log |grep temp
Tips: If you are unsure of the path , have access to find Command find mysqld.log file 
(2) Sign in with a temporary password MySql
mysql -uroot -ppCg3+El.c#ao

(3) modify root User password
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ' password ';
Here may be a hint Your password does not satisfy the current policy requirements, Your password does not meet the requirements of the current regulations , You can either make your password a little more complicated , Or lower the password verification rules .
stay Linux Installation on MySQL A plug-in for verifying passwords will be installed automatically , The default password checking policy requires that the password must contain : Case letters 、 Numbers and special symbols , And the length cannot be less than 8 position . Whether the new password conforms to the current policy when changing the password , If you are not satisfied, you will be prompted ERROR;
So you can set this limit to a smaller number of digits , Lower the complexity type
# Adjust password complexity check to simple type
set global validate_password.policy = 0;
# Set the minimum number of digits of password to 9 position
set global validate_password.length = 9;
You can set a simpler password .

(4) Create user and permission assignment
default root Users can only the current node localhost visit , Is not remotely accessible

Create user commands :
Grammar format :CREATE USER < user name > [ IDENTIFIED ] BY [ PASSWORD ] < password >
# mysql 8.0 following
create user 'siteweb'@'%' IDENTIFIED BY 'siteweb1!';
create user 'siteweb'@'%' identified by 'siteweb1!'; # grant root Remote permissions
# mysql 8.0
create user 'siteweb'@'%' IDENTIFIED WITH mysql_native_password BY 'siteweb1!';
Tips: mysql8.0 The default password authentication for is no longer password . So when you create a user ,create user ‘username’@‘%’ identified by ‘password’; The client cannot connect to the service , So when creating users, you need to add WITH mysql_native_password

After you create a user, you need to assign permissions to the user
grant all privileges on *.* to 'siteweb'@'%'; # to root The user grants remote permission
flush privileges; # Refresh the permissions
mysql> grant all privileges on *.* to 'siteweb'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select host,user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | root |
| % | siteweb |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+------------------+
6 rows in set (0.00 sec)
5、 Confirm that the configuration is in effect
mysql> show global variables like '%lower_case%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_file_system | OFF |
| lower_case_table_names | 1 |
+------------------------+-------+
2 rows in set (0.00 sec)
边栏推荐
猜你喜欢

【LeetCode】3. Merge Two Sorted Lists·合并两个有序链表

Lucene hnsw merge optimization

Analysis of the problems of the 10th Blue Bridge Cup single chip microcomputer provincial competition

Various postures of CS without online line

Analysis of the ninth Blue Bridge Cup single chip microcomputer provincial competition

Go language foundation ----- 19 ----- context usage principle, interface, derived context (the multiplexing of select can be better understood here)

Project experience sharing: Based on mindspore, the acoustic model is realized by using dfcnn and CTC loss function

Shengsi mindspire is upgraded again, the ultimate innovation of deep scientific computing

Go language foundation ----- 18 ----- collaboration security, mutex lock, read-write lock, anonymous lock, sync Once

How long is the fastest time you can develop data API? One minute is enough for me
随机推荐
【MySQL 12】MySQL 8.0.18 重新初始化
Go language - loop statement
昇思MindSpore再升级,深度科学计算的极致创新
技术干货|百行代码写BERT,昇思MindSpore能力大赏
技术干货|AI框架动静态图统一的思考
华为交换机Console密码重置、设备初始化、默认密码
Go language foundation ----- 13 ----- file
Analysis of the problems of the 12th Blue Bridge Cup single chip microcomputer provincial competition
Vertx multi vertical shared data
Why is data service the direction of the next generation data center?
Unified handling and interception of exception exceptions of vertx
Iterm2设置
pgAdmin 4 v6.11 发布,PostgreSQL 开源图形化管理工具
List exercises after class
PAT甲级 1027 Colors in Mars
【MySQL 13】安装MySQL后第一次修改密码,可以可跳过MySQL密码验证进行登录
PAT甲级 1030 Travel Plan
Logging log configuration of vertx
Leetcode 213: looting II
【MindSpore论文精讲】AAAI长尾问题中训练技巧的总结