linux下使用RPM安装mysql5.7.17
程序员文章站
2023-11-30 09:00:28
linux下mysql5.7 rpm安装方式记录,供大家参考,具体内容如下
删除旧包:
# rpm -qa | grep -i mysql
# rpm -ev...
linux下mysql5.7 rpm安装方式记录,供大家参考,具体内容如下
删除旧包:
# rpm -qa | grep -i mysql # rpm -ev mysql-libs-* --nodeps
安装rpm包:
# rpm -ivh mysql-community-common-5.7.17-1.el7.x86_64.rpm # rpm -ivh mysql-community-libs-5.7.17-1.el7.x86_64.rpm # rpm -ivh mysql-community-client-5.7.17-1.el7.x86_64.rpm # rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm
启动、停止:
# service mysqld start # service mysqld stop # service mysqld status
初始随机密码:
# cat /var/log/mysqld.log | more
修改初始密码及授权远程访问:
# mysql -uroot -p mysql> set password='pwd@123456'; mysql> grant all privileges on *.* to 'root'@'%' identified by 'pwd@123456';
密码复杂度属性:
mysql> set global validate_password_policy=0;
validate_password_policy有以下取值:(默认是1,即medium,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。)
修改数据目录:
新目录需要给mysql用户授权,mysqld_safe日志文件授权,关闭selinux(没找到相关策略设置的方法)
# mkdir /data/mysql/data # mv /var/lib/mysql/* /data/mysql/data/ # mkdir /data/mysql/log # chown mysql:mysql -r /data/mysql # touch mysqld_safe.log # chown mysql:mysql mysqld_safe.log # vi /etc/my.cnf /** [client] port = 3306 socket = /data/mysql/log/mysql.sock default-character-set=utf8 [mysql] no-auto-rehash socket=/data/mysql/log/mysql.sock default-character-set=utf8 [mysqld] port = 3306 socket = /data/mysql/log/mysql.sock character-set-server=utf8 lower_case_table_names=1 basedir=/usr datadir=/data/mysql/data log-error=/data/mysql/log/error.log pid-file=/data/mysql/log/mysql.pid init_connect='set names utf8' symbolic-links=0 skip-external-locking key_buffer_size = 16m max_allowed_packet = 1m table_open_cache = 64 sort_buffer_size = 512k net_buffer_length = 8k read_buffer_size = 256k read_rnd_buffer_size = 512k myisam_sort_buffer_size = 8m [mysqld_safe] log-error=/data/mysql/log/mysqld_safe.log */ # getenforce enforcing # setenforce 0 # vi /etc/selinux/config /** # this file controls the state of selinux on the system. # selinux= can take one of these three values: # enforcing - selinux security policy is enforced. # permissive - selinux prints warnings instead of enforcing. # disabled - no selinux policy is loaded. #selinux=enforcing selinux=disabled # selinuxtype= can take one of these two values: # targeted - targeted processes are protected, # mls - multi level security protection. selinuxtype=targeted */ # service mysqld start
其他命令:
# mysqladmin -u root -p password mysql> select version(); # chkconfig --list # chkconfig --level 345 mysqld on # netstat -na | grep 3306
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。