Linux中修改MySql配置文件

windows安装mysql8.0.31遇到的问题
1.安装时 mysqld   --initialize   --console
--character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release.
Please consider using UTF8MB4 in order to be unambiguous.
解决办法:1>将my.ini中所有的utf8改为UTF8MB4
     2>将安装目录下生成的data目录删掉,重新执行 mysqld --initialize --console

2.执行 mysqld --install
报错:Install/Remove of the Service Denied!
解决办法:将cmd窗口以管理员身份打开(找不到在搜索栏查找)


Linux中修改MySQL配置文件my.cnf
1.查找my.cnf文件:which mysql
2.在查询出来的MySQL路径后加上--verbose --help | grep -A 1 'Default options',即可看到my.cnf的路径 上图红框中的提示信息是指,首先读取的是 /etc/my.cnf 文件,如果前一个文件不存在则继续读 /etc/mysql/my.cnf 文件,依此类推,如若还不存在便会去读/usr/etc/my.cnf文件。 使用cd命令切换到对应的目录下,使用vi命令进入my.cnf文件进行查看编辑。如: MySQL配置文件内容可以参考如下: [client] port=3306 [mysql] no-beep [mysqld] #服务端口号 默认3306 port = 3306 #mysql安装根目录 basedir = /usr/local/mysql #mysql数据文件所在位置 datadir = /usr/local/mysql/data #密码认证插件 default_authentication_plugin=caching_sha2_password #默认存储引擎 default-storage-engine=INNODB #开启严格模式 sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" #用文件记录日志 log-output=FILE #关闭日志输出 general-log=0 #日志文件名称 general_log_file="DESKTOP-HB42AU2.log" 开启慢查询日志 slow_query_log = 1 #慢查询日志文件名称 slow_query_log_file = slow.log #大于多少秒的执行SQL被记录在慢查询日志 long_query_time=10 #错误日志名称
log-error="DESKTOP-HB42AU2.err"
#数据库ID server
-id=1 #把表名转换为小写 lower_case_table_names=1 #导入导出数据的目录地址 sercure-file-priv= "/usr/local/mysql/uploads" #最大连接数 max_connections=151 table_open_cache=2000 tmp_table_size=16M #线程数量 thread_cache_size=10 myisam_max_sort_file_size=100G myisam_sort_buffer_size=8M key_buffer_size=8M read_buffer_size=0 read_rnd_buffer_size=256K sort_buffer_size=256K

 

posted @ 2021-04-15 21:23  景、  阅读(6431)  评论(0编辑  收藏  举报