安装软件
配置软件源:/etc/yum.repos.d/mysql-community.repo
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-connectors-community-el7-$basearch/
enabled=1
gpgcheck=0
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
[mysql-tools-community]
name=MySQL Tools Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-tools-community-el7-$basearch/
enabled=1
gpgcheck=0
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
[mysql-8.0-community]
name=MySQL 8.0 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-$basearch/
enabled=1
gpgcheck=0
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
禁用系统自带mysql模块
yum module disable mysql
安装mysql服务端
yum install mysql-community-server
配置 mysql8不区分大小写
必须在数据库启动前配置
lower_case_table_names=0 表名存储为给定的大小和比较是区分大小写的
lower_case_table_names = 1 表名存储在磁盘是小写的,但是比较的时候是不区分大小写
lower_case_table_names=2 表名存储为给定的大小写但是比较的时候是小写的
unix,linux下lower_case_table_names默认值为 0 .Windows下默认值是 1 .Mac OS X下默认值是 2
修改/etc/my.cnf
,在最后一行添加
lower_case_table_names=1
启动mysql
systemctl enable --now mysqld
查看默认root密码 cat /var/log/mysqld.log
[root@hr-test ~]# cat /var/log/mysqld.log
2023-08-03T05:19:39.377361Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.34) initializing of server in progress as process 2066
2023-08-03T05:19:39.383196Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-08-03T05:19:39.615099Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-08-03T05:19:40.221227Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: i8ybtu&k&GoK
使用默认密码初始化mysqlmysql_secure_installation
修改默认root密码、删除匿名用户、禁止root远程登陆、删除test数据库
查看lower_case_table_names
mysql -uroot -p
mysql> show variables like 'lower_case_table_names';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_table_names | 1 |
+------------------------+-------+
1 row in set (0.00 sec)
mysql> quit
允许创建函数
解决Mysql报错:This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its de
log_bin_trust_function_creators=1
关闭严格模式
STRICT_TRANS_TABLES : 严格模式
NO_ENGINE_SUBSTITUTION : 无引擎提交
PAD_CHAR_TO_FULL_LENGTH : 填补字符到全长度
编辑MySQL配置文件/etc/my.cnf
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION
保存、重启mysql
事务隔离级别
read uncommitted(读未提交)
read committed(读提交)
repeatable read(重复读)
Serializable(序列化)
编辑MySQL配置文件/etc/my.cnf
[mysqld]
transaction_isolation = READ-COMMITTED
保存、重启mysql
日志时区不对
编辑MySQL配置文件/etc/my.cnf
log_timestamps=system
日志存在大量反查信息和错误信息
编辑MySQL配置文件/etc/my.cnf
skip-name-resolve
完成
评论