wget dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum localinstall mysql57-community-release-el7-7.noarch.rpm
yum方式安裝:
yum install mysql-community-server
使用tar包安裝:https://www.jianshu.com/p/276d59cbc529
登錄成功后更新root用戶密碼:ALTER USER root@localhost IDENTIFIED BY '123456';
貼一下/etc/my.cnf:
[mysqld] datadir=/usr/local/mysql/data socket=/usr/local/mysql/data/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd [client] port=3306 socket=/usr/local/mysql/data/mysql.sock [mysqld_safe] log-error=/usr/local/mysql/data/error.log pid-file=/usr/local/mysql/data/run/mysql.pid # # include all files from the config directory # !includedir /etc/my.cnf.d
/etc/my.cnf.d/mysql-clients.cnf:
# # These groups are read by MariaDB command-line tools # Use it for options that affect only one utility # [mysql] [mysql_upgrade] [mysqladmin] [mysqlbinlog] [mysqlcheck] [mysqldump] [mysqlimport] [mysqlshow] [mysqlslap]
安裝完成啟動時報錯:
Starting mysqld (via systemctl): Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.]
SELinux is preventing /usr/sbin/mysqld from write access on the directory . For complete SELinux mes
解決辦法:
1、/usr/sbin/sestatus -v ##如果SELinux status參數為enabled即為開啟狀態 SELinux status: enabled 2、getenforce ##也可以用這個命令檢查
關閉SELinux:
1、臨時關閉(不用重啟機器): 復制代碼代碼如下: setenforce 0 #設置SELinux 成為permissive模式 #setenforce 1 設置SELinux 成為enforcing模式 2、修改配置文件需要重啟機器: 修改/etc/selinux/config 文件 將SELINUX=enforcing改為SELINUX=disabled 重啟機器即可
修改root用戶密碼時報錯:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysqladmin: unable to change password; error: 'Column count of mysql.user is wrong. Expected 45, found 43. Created with MySQL 50638, now running 50722. Please use mysql_upgrade to fix this error.'
解決辦法:使用如下命令
mysql_upgrade
再次使用命令修改密碼:
/usr/bin/mysqladmin -u root password 'root'
修改成功。