YUM 安装 mysql8.0 ,重置密码等

yum 安装十分简单, 如果安装有mariadb 需要先移除, 并删除掉 repo文件

yum remove MariaDB MariaDB-server 
rm /etc/yum.repos.d/MariaDB.repo
rm -rf /var/lib/mysql
rm -rf /etc/my.conf
rm -rf /etc/my.conf.d

安装

rpm -ivh https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
yum install -y mysql mysql-server

初始化, 需要先删除 rm -rf /var/lib/mysql

mysqld --initialize --console

mysql8.0安装后会自动生成密码, 找到默认密码

[root@localhost ~]#  grep 'temporary password' /var/log/mysqld.log
2019-06-29T01:35:29.486721Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Q,Fflgfye6w.
[root@localhost ~]# 

初始化

mysql_secure_installation

开启远程登陆

CREATE USER 'root'@'%' IDENTIFIED BY 'Q,Fflgfye6w.'; 
GRANT ALL ON *.* TO 'root'@'%'; 
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Q,Fflgfye6w.';
FLUSH PRIVILEGES;

# 修改本地
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Q,Fflgfye6w.';

开启可以设置简单密码

set global validate_password.policy=0;
set global validate_password.length=4;

忘记密码

修改 my.cnf

echo 'skip-grant-tables' >> /etc/my.cnf
systemctl restart mysqld

清空密码

[root@izbp13d8lkv9kzxvm67ax5z conf.d]# mysql 
mysql> use mysql;
mysql> update user set authentication_string = '' where user = 'root';

针对1G 服务器配置


#慢日志
long_query_time = 1
slow_query_log = ON
slow_query_log_file = /var/log/mysql-slow.log
log_queries_not_using_indexes = ON

performance_schema=Off
table_definition_cache=300
table_open_cache=300
performance_schema_max_table_instances=100
innodb_buffer_pool_size=8M
innodb_log_file_size=8M
innodb_flush_log_at_trx_commit=0
innodb_log_buffer_size=2M
innodb_thread_concurrency=1
key_buffer_size=8M
tmp_table_size=32M
read_buffer_size=2M
read_rnd_buffer_size=2M
sort_buffer_size=8M
max_connections=100

# 忽略大小写
lower_case_table_names=1

# 开启独享表空间,并指定ibdata1大小为128M 可以修改为1G,ibdata2大小64M,自动扩张。
innodb_data_home_dir = /var/lib/mysql
innodb_data_file_path = ibdata1:128M;ibdata2:64M:autoextend
innodb_file_per_table=1

参考 https://dev.mysql.com/downloads/repo/yum/

https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html#yum-repo-setup

https://dev.mysql.com/doc/refman/5.7/en/replace-third-party-yum.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注

Captcha Code