正文开始 <p>http://blog.csdn.net/hanimashi/article/details/53225025</p><p><br /></p><p>提前步骤:1.在Centos 7上先要卸载mariadb-lib</p><p></p><pre> [root@centos-linux ~]# rpm -qa|grep mariadbmariadb-libs-5.5.44-2.el7.centos.x86_64
[root@centos-linux ~]# rpm -e mariadb-libs-5.5.44-2.el7.centos.x86_64 --nodeps </pre> 2.到mysql官网下载liunx 64位版本,或者使用liunx指令网络安装官网下载:<a target="_blank" href="http://www.mysql.com/">http://www.mysql.com/</a>我这里分享我自己在mysql网站下载的最新版本:链接: http://pan.baidu.com/s/1kVhmHWb 密码: 2ikt下载后,放置到Centos 服务器的/usr/local/ 文件夹上解压 :<p></p><p></p><pre> [root@centos-linux ~]# ls mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar
[root@centos-linux ~]# tar xvf mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar </pre> 解压后,出现如下文件:<p></p><p></p><pre> mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
mysql-community-devel-5.7.16-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.16-1.el7.x86_64.rpm
mysql-community-libs-5.7.16-1.el7.x86_64.rpm
mysql-community-common-5.7.16-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.16-1.el7.x86_64.rpm
mysql-community-test-5.7.16-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.16-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.16-1.el7.x86_64.rpm
mysql-community-server-5.7.16-1.el7.x86_64.rpm
mysql-community-client-5.7.16-1.el7.x86_64.rpm
mysql-community-embedded-5.7.16-1.el7.x86_64.rpm </pre> 依次执行(几个包有依赖关系,所以执行有先后)下面命令安装:<p></p><p></p><pre>rpm -ivh mysql-community-common-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-minimal-debuginfo-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-embedded-compat-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-test-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-embedded-devel-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-minimal-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-embedded-5.7.16-1.el7.x86_64.rpm</pre> 数据库初始化:在 Liunx 系统中,为了保证数据库目录为与文件的所有者为 mysql 登陆用户,如果你是以 root 身份运行 mysql 服务,需要执行下面的命令初始化<p></p><p></p><pre> <span style="white-space:pre"> </span>[root@centos-linux ~]# mysqld --initialize --user=mysql </pre> 如果是以 mysql 身份运行,则可以去掉 --user 选项。另外 --initialize 选项默认以“安全”模式来初始化,则会为 root 用户生成一个密码并将该密码标记为过期,登陆后你需要设置一个新的密码,而使用 --initialize-insecure 命令则不使用安全模式,则不会为 root 用户生成一个密码。这里演示使用的 --initialize 初始化的,会生成一个 root 账户密码,密码在log文件里<p></p><p></p><pre>[root@localhost local]# cat /var/log/mysqld.log
2016-11-18T05:17:06.439015Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use -- explicit_defaults_for_timestamp server option (see documentation for more details).
2016-11-18T05:17:06.619744Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-11-18T05:17:06.656070Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-11-18T05:17:06.715702Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 3f94e95c-ad4e-11e6-ac8b-000c29994ce5.
2016-11-18T05:17:06.716475Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-11-18T05:17:06.717114Z 1 [Note] A temporary password is generated for root@localhost: <.xOzij-F2vr </pre> 修改 root 密码该密码被标记为过期了,如果想正常使用还需要修改密码mysql> show databases;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.以前的 password()函数将会被抛弃,官方建议使用下面的命令来修改密码mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '460502Kfc';<br />不过要注意mysql 5.7 设定密码和之前版本密码不能太简单,详情请看这里解释:<a target="_blank" href="https://blog.laily.net/archives/571/">https://blog.laily.net/archives/571/</a><br />设置root外网ip访问,并对其授权:创建一个普通用户 sa ,密码是 some_passCREATEUSER'sa'@'%'IDENTIFIEDBY'some_pass';给这个用户授予 SELECT,INSERT,UPDATE,DELETE 的远程访问的权限,这个账号一般用于提供给实施的系统访问GRANTSELECT,INSERT,UPDATE,DELETEON *.*TO'sa'@'%';创建一个管理员用户 admin 账号 ,密码是 some_passCREATEUSER'admin'@'%'IDENTIFIEDBY'some_pass';给这个用户授予所有的远程访问的权限。这个用户主要用于管理整个数据库、备份、还原等操作。GRANT ALL ON *.*TO'admin'@'%';使授权立刻生效flushprivileges;<br />启动mysql 服务器指令:启动 MySQL Serversystemctlstart mysqld查看 MySQL Server 状态systemctl status mysqld关闭 MySQL Serversystemctlstop mysqld<br />防火墙设置:(预防iP可以ping接,但是navicat并不能连接的情况)远程访问 MySQL, 需开放默认端口号 3306.方式1:iptables(CentOS 7.x版本之前用法,不推荐)打开 iptables 的配置文件:vi /etc/sysconfig/iptables修改*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMIT在里面加入这2行:-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT-A RH-Firewall-1-INPUT -m state –state NEW -m udp -p udp –dport 3306 -j ACCEPT改为*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT-A RH-Firewall-1-INPUT -m state –state NEW -m udp -p udp –dport 3306 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMIT如果该 iptables 配置文件 不存在,先执行 yum install iptables-services 安装执行 iptables 重启生效service iptables restart方式2:firewall-cmd(推荐)执行firewall-cmd --permanent --zone=public --add-port=3306/tcpfirewall-cmd --permanent --zone=public --add-port=3306/udp这样就开放了相应的端口。执行firewall-cmd --reload使最新的防火墙设置规则生效。<br />还有其他设置与补充可以查阅这篇文章:<a target="_blank" href="http://www.centoscn.com/mysql/2016/0315/6844.html">http://www.centoscn.com/mysql/2016/0315/6844.html</a><br /><p></p><p><br /></p><p><br /></p>
正文结束 |
Mysql Innodb 引擎优化 参数 | CentOS 7 用yum安装 MySQL rpm |