Centos7 安装MySQL5.7
程序员文章站
2022-04-14 14:27:07
...
有安装旧版本mysql:
1、杀死mysql进程:pkill -9 mysqld
2、rpm -qa|grep -i mysql
3、用命令 yum -y remove
yum -y remove mysql-community-client-5.6.38-2.el7.x86_64
卸载不掉的用 rpm -ev
依次卸载 直到没有
新机:
1、下载mysql的repo源 这个安装的mysql5.7.20
cd /usr/local/src/
wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
yum -y install mysql-server
2、一路安装下去,各个配置文件的路径:
配置文件:/etc/my.cnf
日志文件:/var/log/var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件: /var/run/mysqld/mysqld.pid
3、配置my.cnf:vim /etc/my.cnf
[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
server_id = 1
expire_logs_days = 3
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
4、启动mysql服务:service mysqld restart
5、重置密码:
查询初始密码:grep 'password' /var/log/mysqld.log
修改密码:alter user 'root'@'localhost' identified by '***';
刷新:flush privileges
6、添加用户:create user '***'@'%' identified by '***';
7、给用户授权:grant all on *.* to '***'@'%' identified by '***' with grant option;
8、 限制IP登录将%改成IP地址
下一篇: nodejs基础应用