当前位置:网站首页>[MySQL 12] MySQL 8.0.18 reinitialization
[MySQL 12] MySQL 8.0.18 reinitialization
2022-07-03 07:43:00 【Rusty well began】
1、 Backup MySQL database
Reinitialize mysql. Simply reset ,“ Restore factory settings ”. After reset , All data will be cleared and lost , So be sure to back up important databases , Namely data The database files under the directory
2、 Out of Service
Before modifying the configuration , Please put mysql Service stopped . Execute the following command :
systemctl stop mysqld.service
3、 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
4、 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 *
5、 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
6、 To configure my.cnf file
If you need to be case sensitive , Need to be in my.cnf Add
lower_case_table_names

Use vim Editor Editor /etc/my.cnf file , as follows :
[[email protected] lib]# vim /etc/my.cnf
Save configuration information .
7、 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
8、 start-up MySql service
systemctl start mysqld.service
9、 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 .
10、 Create user and permission assignment
(1) 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
(2) 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)
11、MySQL 8.0.18 Whether the case sensitive problem is effective
If the MySQL 8.0.18 Case sensitive words , You can check whether the configuration is effective at this time
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)
边栏推荐
- Pat grade a 1027 colors in Mars
- Robots protocol
- The babbage industrial policy forum
- The babbage industrial policy forum
- Sent by mqtt client server of vertx
- Comparison of advantages and disadvantages between most complete SQL and NoSQL
- Industrial resilience
- Project experience sharing: realize an IR Fusion optimization pass of Shengsi mindspire layer
- PAT甲级 1030 Travel Plan
- Go language foundation ----- 13 ----- file
猜你喜欢

Es writing fragment process

Go language foundation ----- 05 ----- structure
![[coppeliasim4.3] C calls UR5 in the remoteapi control scenario](/img/ca/2f72ea3590c358a6c9884aaa1a1c33.png)
[coppeliasim4.3] C calls UR5 in the remoteapi control scenario

Harmonyos third training notes

Go language foundation ------ 12 ------ JSON

項目經驗分享:實現一個昇思MindSpore 圖層 IR 融合優化 pass
![[mindspire paper presentation] summary of training skills in AAAI long tail problem](/img/34/9c9ec1b94edeecd4a3e7f20fdd8356.png)
[mindspire paper presentation] summary of training skills in AAAI long tail problem

PAT甲级 1028 List Sorting

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

Go language foundation ----- 13 ----- file
随机推荐
Go language foundation ----- 03 ----- process control, function, value transfer, reference transfer, defer function
Pat grade a 1029 median
Lucene introduces NFA
Vertx metric Prometheus monitoring indicators
Redis配置文件
go语言-循环语句
Introduction of novel RNA based cancer therapies
Professor Zhang Yang of the University of Michigan is employed as a visiting professor of Shanghai Jiaotong University, China (picture)
Various postures of CS without online line
Harmonyos third training notes
技术干货 | AlphaFold/ RoseTTAFold开源复现(2)—AlphaFold流程分析和训练构建
HarmonyOS第三次培训笔记
华为交换机基础配置(telnet/ssh登录)
An overview of IfM Engage
Analysis of the problems of the 10th Blue Bridge Cup single chip microcomputer provincial competition
【MySQL 11】怎么解决MySQL 8.0.18 大小写敏感问题
优质博客——
Go language foundation ----- 05 ----- structure
OSPF experiment
Es writing fragment process