mysql安装-rpm方式
环境
系统:centos7.9
安装包:mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar(下载:https://dev.mysql.com/downloads/mysql/5.7.html)
安装
-
上传安装包到/opt/mysql 并且解压
# cd /opt/mysql/ # tar xvf mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar mysql-community-client-5.7.38-1.el7.x86_64.rpm mysql-community-common-5.7.38-1.el7.x86_64.rpm mysql-community-devel-5.7.38-1.el7.x86_64.rpm mysql-community-embedded-5.7.38-1.el7.x86_64.rpm mysql-community-embedded-compat-5.7.38-1.el7.x86_64.rpm mysql-community-embedded-devel-5.7.38-1.el7.x86_64.rpm mysql-community-libs-5.7.38-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.38-1.el7.x86_64.rpm mysql-community-server-5.7.38-1.el7.x86_64.rpm mysql-community-test-5.7.38-1.el7.x86_64.rpm -
查看系统中的mariadb包并且卸载
# rpm -qa | grep mariadb # rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64 -
安装依赖
# yum install -y perl net-tools -
安装mysql-community-common
# rpm -ivh mysql-community-common-5.7.38-1.el7.x86_64.rpm -
安装mysql-community-libs
# rpm -ivh --force --nodeps mysql-community-libs-5.7.38-1.el7.x86_64.rpm -
安装mysql-community-client
# rpm -ivh mysql-community-client-5.7.38-1.el7.x86_64.rpm -
安装mysql-community-server
# rpm -ivh --force --nodeps mysql-community-server-5.7.38-1.el7.x86_64.rpm -
查看mysql客户端是否安装成功
# which mysql /usr/bin/mysql -
编辑配置文件
在[mysqld]段增加一行:skip-grant-tables 跳过本地数据库权限验证 (生产慎用)
# vim /etc/my.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html [mysqld] skip-grant-tables # # 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=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid -
启动服务
# systemctl start mysqld.service
设置用户
-
进入客户端设置用户
# mysql # 修改root用户密码 mysql> update mysql.user set authentication_string=password('root') where user='root'; # 刷新权限 mysql> flush privileges; -
编辑配置文件
删掉skip-grant-tables 并且重启
# vim /etc/my.cnf skip-grant-tables # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html [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=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid ~# systemctl restart mysqld.service -
root用户密码登录
# mysql -uroot -proot -
设置密码的验证强度等级
set global validate_password_policy=LOW; -
设置密码长度
set global validate_password_length=4; -
修改密码
set password=password('root123456'); -
开启远程登录权限 mysql不允许用户名密码一致并且拥有远程登录权限 负责报错
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
grant all privileges on *.* to 'root'@'%' identified by 'root123456' with grant option; -
刷新权限
flush privileges; -
退出mysql客户端
exit
by makj
本文来自博客园,作者:makj,转载请注明原文链接:https://www.cnblogs.com/makj/p/16428997.html

浙公网安备 33010602011771号