1.移除mariadb
rpm -qa|grep mariadb
yum remove mariadb
ls /etc/my.cnf
ll /var/lib/mysql/
rm -rf /etc/my.cnf
rm -rf /var/lib/mysql/
systemctl service mysql
2.处理centos 系统信息
cat /etc/redhat-release
3.处理之前版本的mysql
rpm -qa | grep -i mysql
yum -y remove MySQL-*
find / -name mysql
4.安装mysql
sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
sudo yum --enablerepo=mysql80-community install mysql-community-server
sudo service mysqld start
service mysqld status
5.配置mysql
grep "A temporary password" /var/log/mysqld.log
mysql -uroot -p
alter user user() identified by "Aa123456@";
use mysql;
select user,plugin from user where user='root';
select user,host from user;
alter user 'root'@'localhost' identified with mysql_native_password by 'Aa123456@';
select user,plugin from user where user='root';
find / -name my.cnf
default_authentication_plugin=mysql_native_password
service mysql.server restart
CREATE USER 'root'@'%' IDENTIFIED BY 'Aa123456@';
GRANT ALL ON *.* TO 'root'@'%';
ALTER USER 'root'@'%' IDENTIFIED BY 'Aa123456@' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Aa123456@';
FLUSH PRIVILEGES;
vi /etc/my.cnf
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
5.1Mysql初始化密码错误
FLUSH PRIVILEGES;
6.处理mysql端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
systemctl restart firewalld.service
7.mysql 常用命令
service mysqld start
service mysqld stop
service mysqld restart
service mysqld status
8.查看已经开启的服务
systemctl list-unit-files|grep enabled
9.服务器优化处理
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8mb4
max_connections=200
max_connect_errors=10
default-storage-engine=INNODB
innodb_buffer_pool_size=8G
innodb_max_dirty_pages_pct=30
innodb_open_files = 500
innodb_log_buffer_size = 2M
long_query_time=1
slow-query-log=On
slow_query_log_file="mysql_slow_query.log"
transaction_isolation = READ-COMMITTED
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
[mysql]
default-character-set=utf8mb4