1.检查是否已安装mysql
yum list installed mysql*
2.卸载现有Mysql
yum remove Mysql**(当前版本,上一步命令查询出来的结果)
3.下载rpm文件
wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
4.接着执行这句,解释一下,这个rpm还不是mysql的安装文件,只是两个yum源文件,执行后,在/etc/yum.repos.d/ 这个目录下多出mysql-community-source.repo和mysql-community.repo
rpm -ivh mysql-community-release-el6-5.noarch.rpm
5.安装mysql 服务器命令(一路yes):
yum install mysql-community-server
6.安装成功后,启动服务
service mysqld start
启动后,最好查看一下启动日志是否有错误信息,日志目录:/var/log/mysqld.log
1)错误1:
2017-11-27 19:51:05 6120 [Note] Plugin 'FEDERATED' is disabled.
2017-11-27 19:51:05 6120 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-11-27 19:51:05 6120 [Note] InnoDB: The InnoDB memory heap is disabled
2017-11-27 19:51:05 6120 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-11-27 19:51:05 6120 [Note] InnoDB: Memory barrier is not used
2017-11-27 19:51:05 6120 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-11-27 19:51:05 6120 [Note] InnoDB: Using Linux native AIO
2017-11-27 19:51:05 6120 [Note] InnoDB: Using CPU crc32 instructions
2017-11-27 19:51:05 6120 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-11-27 19:51:05 6120 [Note] InnoDB: Completed initialization of buffer pool
2017-11-27 19:51:05 6120 [ERROR] InnoDB: auto-extending 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 (relevant if non-zero) pages!
2017-11-27 19:51:05 6120 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2017-11-27 19:51:05 6120 [ERROR] Plugin 'InnoDB' init function returned error.
2017-11-27 19:51:05 6120 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-11-27 19:51:05 6120 [ERROR] Unknown/unsupported storage engine: InnoDB
2017-11-27 19:51:05 6120 [ERROR] Aborting
针对以上报错,需要在/var/lib/mysql路径下删除rm ibdata1 ib_logfile0 ib_logfile1
三个文件
2)错误2:
2017-11-28 13:24:36 7078 [ERROR] Missing system table mysql.proxies_priv; please run mysql_upgrade to create it
根据提示需要执行更新命令:mysql_upgrade -u root -p
7.mysql 5.6版本后,默认root用户应该有初始密码,该密码只能用作登陆,具体修改密码步骤可参考https://www.cnblogs.com/silentdoer/articles/7258232.html
8.对局域网开通访问权限 进入mysql执行:
mysql> use mysql;
mysql> select user,host from user;
+------+-----------------------+
| user | host |
+------+-----------------------+
| root | 127.0.0.1 |
| root | 172.16.% |
| | localhost |
| root | localhost |
| | localhost.localdomain |
| root | localhost.localdomain |
+------+-----------------------+
该结果表示root用户只能用户localhost连接访问。需要更新表信息:
mysql> update user set host='%' where user='root';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
附mysql安装步骤另外教程链接:https://www.cnblogs.com/xubiao/p/7832165.html