正文开始 <p>一 安装环境</p><p>(1)<a href="http://www.linuxidc.com/topicnews.aspx?tid=14" target="_blank" title="CentOS">CentOS</a>版本:CentOS-7</p><p>查看方法:</p><p>[root@linuxidc 桌面]# cat /etc/<a href="http://www.linuxidc.com/topicnews.aspx?tid=10" target="_blank" title="RedHat">RedHat</a>-release</p><p>CentOS Linux release 7.0.1406 (Core)</p><p>来源:官网下载</p><p>下载地址:http://www.centos.org/</p><p>(2)MySQL版本:MySQL-5.6.22</p><p>来源:官网下载</p><p>下载地址:<a href="https://edelivery.oracle.com/EPD/Search/handle_go">https://edelivery.oracle.com/EPD/Search/handle_go</a></p><p>或者百度网盘:<a href="http://pan.baidu.com/s/1o7zBDI6" target="_blank">http://pan.baidu.com/s/1o7zBDI6</a></p><p>名称:MySQL Database 5.6.22 RPM for <a href="http://www.linuxidc.com/topicnews.aspx?tid=12" target="_blank" title="Oracle">Oracle</a> Linux / RHEL 7 x86 (64bit)</p><p>1. 解压下载的zip包,会发现有以下几个rpm包:</p><p>MySQL-client-advanced-5.6.22-1.el7.x86_64.rpm</p><p>MySQL-devel-advanced-5.6.22-1.el7.x86_64.rpm</p><p>MySQL-embedded-advanced-5.6.22-1.el7.x86_64.rpm</p><p>MySQL-server-advanced-5.6.22-1.el7.x86_64.rpm</p><p>MySQL-shared-advanced-5.6.22-1.el7.x86_64.rpm</p><p>MySQL-shared-compat-advanced-5.6.22-1.el7.x86_64.rpm</p><p>MySQL-test-advanced-5.6.22-1.el7.x86_64.rpm</p><p>2. 卸载MariaDB</p><p>如果直接点击rpm包安装会得到错误提示。因为CentOS的默认数据库已经不再是MySQL了,而是MariaDB,为什么呢?</p><p>MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。</p><p>查看当前安装的mariadb包:</p><p>[root@linuxidc 桌面]# rpm -qa | grep mariadb</p><p>将它们统统强制性卸载掉:</p><p>[root@linuxidc 桌面]# rpm -e --nodeps mariadb-libs-5.5.35-3.el7.x86_64</p><p>[root@linuxidc 桌面]# rpm -e --nodeps mariadb-5.5.35-3.el7.x86_64</p><p>[root@linuxidc 桌面]# rpm -e --nodeps mariadb-server-5.5.35-3.el7.x86_64</p><p>3. 安装MYSQL</p><p></p>rpm -ivh MySQL-client-advanced-5.6.22-1.el7.x86_64.rpm <br />rpm -ivh MySQL-devel-advanced-5.6.22-1.el7.x86_64.rpm <br />rpm -ivh MySQL-server-advanced-5.6.22-1.el7.x86_64.rpm <br />rpm -ivh MySQL-embedded-advanced-5.6.22-1.el7.x86_64.rpm <br />rpm -ivh MySQL-shared-compat-advanced-5.6.22-1.el7.x86_64.rpm <br />rpm -ivh MySQL-test-advanced-5.6.22-1.el7.x86_64.rpm <br />rpm -ivh MySQL-shared-advanced-5.6.22-1.el7.x86_64.rpm <br /><p></p><p>4. 启动MYSQL</p><p>[root@linuxidc 桌面]#service mysql start</p><p>得到错误:ERROR!The server quit without updating PID file</p><p>我们这里主要是因为:selinux惹的祸,如果是centos系统,默认会开启selinux。解决方法是关闭它,打开/etc/selinux/config,把SELINUX=enforcing改为SELINUX=disabled后存盘退出重启机器。</p><p>然后再启动mysql就没问题了:</p><p>[root@linuxidc 桌面]#service mysql start</p><p>查看MySQL运行状态:</p><p>[root@linuxidc 桌面]# service mysql status</p><p>SUCCESS! MySQL running (2377)</p><br /><p><br />启动MySQL数据库:<br />[root@iZ23xz8uttcZ ~]# service mysql start<br />Starting MySQL. [ OK ]<br /><br /><br />查看MySQL运行状态:<br />[root@iZ23xz8uttcZ ~]# service mysql status<br />MySQL running (5314) [ OK ]<br /><br /><br /><br />5. 默认root用户登录MYSQL<br /><br /><br />[root@iZ23xz8uttcZ ~]# mysql -u root -p<br /><br /><br />Enter password:<br /><br /><br />ERROR 1045 (28000):Access denied for user 'root'@'localhost' (using password: YES)<br />解决方案:<br />[root@iZ23xz8uttcZ ~]# /etc/init.d/mysql stop <br />[root@iZ23xz8uttcZ ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking & <br />[root@iZ23xz8uttcZ ~]# mysql -u root<br />mysql> UP DATE user SET Password=PASSWORD(’newpassword’) where USER=’root’; <br />mysql> FLUSH PRIVILEGES; <br />mysql> quit <br /><br />ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'<br />解决方案: <br />[root@iZ23xz8uttcZ ~] # service mysql start<br /><br /><br />6 登录MYSQL<br /><br />[root@iZ23xz8uttcZ ~]# mysql -u root -p<br /><br />Enter password: <输入新设的密码newpassword> <br /><br />mysql> show databases;<br /><br />显示数据库:<br /><br />mysql> show databases;<br />+--------------------+<br />| Database |<br />+--------------------+<br />| information_schema |<br />| mysql |<br />| performance_schema |<br />| test |<br />+--------------------+</p><p>4 rows in set (0.02 sec)</p><p> </p><p>至此MySQL已安装成功!!!<br /><br />mysql安装后三个主要的目录及其功能:<br /><br />/var/lib/mysql 数据库文件</p><p>/usr/share/mysql 命令及配置文件</p><p>/usr/bin mysqladmin、mysqldump等命令</p><p>查看所有用户 <br /></p><p>use mysql<br /><br /></p><p>select host,user from user;<br /><br /> up date user set host='%' where user='root'<br /><br /><br /></p>
正文结束 |
Mysql Innodb 引擎优化 参数 | centos支持mysql外部连接;远程连接CentOS的MySQL报错:Cant connect to MySQL server on 'XXX' |