1.查看系统版本信息:
(1)输入命令:uname -a
(2)输入命令:cat /etc/issue
2.确定采用什么方式安装mysql,包安装或者yum安装,本文采用yum安装
3.彻底删除并卸载已安装的mysql:
rpm -qa | grep mysql//查看验证的mysql组件
yum remove mysql mysql-devel mysql-libs mysql-server//你安装的mysql组件
find / -name mysql //将找到的相关东西delete掉
rpm -e mysql // 普通删除模式
rpm -e --nodeps mysql // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
4.安装命令:yum install mysql mysql-server mysql-devel
5.查看安装版本:mysqladmin --version
6.常见问题汇总:
(1).[ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
解决方法:启动命令指定用户service mysqld start --user=root
或者修改my.cnf,mysqld中增加user=root
(2). 重置密码
a.my.cnf中增加skip-grant-tables
b.
mysql> use mysql; ##使用mysql数据库 Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> update user set password=password("123456") where user="root";##更新密码 Query OK, 4 rows affected (0.00 sec) Rows matched: 4 Changed: 4 Warnings: 0 mysql> flush privileges;##刷新权限 Query OK, 0 rows affected (0.00 sec)
(3).[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
解决方法:输入命令:mysql_install_db,重新安装数据目录
(4).Can't find file: './mysql/host.frm'
解决方法:权限不足,重新授权chown mysql *
(5).[error] Can't find messagefile '/usr/share/mysql/errmsg.sys'
解决方法:若linux服务器上存在该文件sudo cp /usr/local/mysql/share/english/errmsg.sys /usr/share/mysql/
否则去官网上下载对应的linux版本的安装包,解压后放到里面
(6).mysql之Unknown storage engine 'InnoDB'
解决方法:在my.cnf文件中增加以下内容以重新配置引擎:
innodb=OFF
ignore-builtin-innodb
skip-innodb
default-storage-engine=myisam
default-tmp-storage-engine=myisam