美文网首页
Centos yum安装mysql

Centos yum安装mysql

作者: 林亚希 | 来源:发表于2019-02-28 09:58 被阅读0次

1. 检查是否安装过mysql

rpm -qa | grep -i mysql

如果有就先卸载

rpm -e MySQL-client-5.6.41-1.el7.x86_64 --nodeps
rpm -e MySQL-devel-5.6.41-1.el7.x86_64  --nodeps
rpm -e MySQL-server-5.6.41-1.el7.x86_64 --nodeps

2. 配置yum源

#查看mysql官方最新源安装包
https://dev.mysql.com/downloads/repo/yum/
#下载MySQL源安装包
sudo wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
#安装MySQL源
sudo yum localinstall mysql57-community-release-el7-8.noarch.rpm
#检查MySQL源是否安装成功
sudo yum repolist enabled | grep "mysql.*-community.*"
#安装MySQL
sudo yum install mysql-community-server

3. 启动mysql

sudo systemctl start mysqld
sudo systemctl status mysqld

4. 登陆mysql

  • 获取默认密码
sudo grep 'temporary password' /var/log/mysqld.log

登陆

mysql -uroot -p 密码

登陆后先更改密码

alter user user() identified by "Esb@1234";
flush privileges;

5. 修改配置

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[client]
socket=/home/data/mysql/mysql.sock
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/home/data/mysql/log/mysqld.log
#pid-file=/home/data/mysql/mysqld.pid
datadir=/home/data/mysql
socket=/home/data/mysql/mysql.sock
character_set_server=utf8mb4
innodb_file_per_table=1

6. 新增用户

CREATE USER 'esb'@'%' IDENTIFIED BY 'Esb@1234';

相关文章

网友评论

      本文标题:Centos yum安装mysql

      本文链接:https://www.haomeiwen.com/subject/qtgcuqtx.html