自己记录一下操作
centeros 6.6是新安装的用来做测试使用, 系统自带的mysql为5.1版本的,安装后发现很多应用包都需要更高版本的,手头有前短时间下载的5.7版本的包,因此决定安装新的包。
1、先查询并卸载mysql的安装包
查询出来mysql的安装包
使用命令
yum list *mysql*
卸载包
yum groupremove mysql*
发现有些没有卸载掉,使用rpm命令卸载
rpm -e --nodeps
2、安装包
全部使用rpm命令安装
rpm -ivh 按照惯例按顺序安装即可
安装完成后,启动mysql出现错误
2016-02-19T16:46:27.214854Z 0 [ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a
different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (re
levant if non-zero) pages!
2016-02-19T16:46:27.214891Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2016-02-19T16:46:27.821030Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2016-02-19T16:46:27.821067Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-02-19T16:46:27.821072Z 0 [ERROR] Failed to initialize plugins.
2016-02-19T16:46:27.821075Z 0 [ERROR] Aborting
这时删除/var/lib/mysql下的三个文件
再次启动mysql,出现错误
2016-02-19T16:51:11.019591Z 0 [ERROR] Fatal error: mysql.user table is damaged. Please run mysql_upgrade.
2016-02-19T16:51:11.019777Z 0 [ERROR] Aborting
使用如下命令,重新初始化mysql
mysqld --initialize --user=mysql
还是报上述错误,删除/var/lib/mysql目录下的所有文件,再次执行初始化命令,成功。
启动mysql成功
3、mysql登录及密码修改
登录
[chb@centeros6 ~]$ mysqladmin -uroot -p root
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
碰到这种情况,安全启动mysql
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql
mysql> update user set authentication_string=PASSWORD('root') where user='root';
Query OK, 1 row affected, 1 warning (0.04 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
修改成功
重新启动mysql也成功
mysql登录后,提示修改密码
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set PASSWORD=Password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> alter user root@localhost PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
密码修改成功,密码也不提示过期了。
4、升级php5.3到5.6.18版本
centeros的yum只支持5.3版本,安装好之后发现需要升级到5.5版本以上,下载源代码编译发现gcc没有配置,嫌麻烦,想办法升级yum
先升级yum的运行环境(6.5)
rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
(7.0)
yum install epel-release
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
查看可以安装的包
yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
安装包
yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof
ok了