一、安装mysql
1.官网下载rpm包
https://dev.mysql.com/downloads/mysql/5.5.html#downloads
wget https://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-server-5.5.62-1.el6.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-client-5.5.62-1.el6.x86_64.rpm
2.安装mysql
rpm -ivh MySQL-server-5.5.62-1.el6.x86_64.rpm
此处报错:
warning: MySQL-server-5.5.62-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libaio.so.1()(64bit) is needed by MySQL-server-5.5.62-1.el6.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.5.62-1.el6.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.5.62-1.el6.x86_64
>解决办法:libaio.so.1()(64bit) is needed by MySQL-server 问题解决办法<
yum install libaio
重新执行安装命令,成功。运行以下命令,验证:
rpm -qa | grep -i mysql
二、启动mysql服务
service mysql start
此时出现错误:
[root@www ~]# service mysql start
Starting MySQL.Logging to '/var/lib/mysql/www.flytop.top.err'.
.. ERROR! The server quit without updating PID file (/var/lib/mysql/www.flytop.top.pid).
>解决办法:Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdom<
mysql_install_db --user=mysql --ldata=/var/lib/mysql/
之后再启动,成功。
三、设置mysql开机自启
查看mysql是否开机自启
chkconfig --list | grep mysql
不太懂这个是什么意思,网上的说法是3,4,5都是on,则已经是开机自启了,如果不是的话,可以执行下面的命令设置自启:
chkconfig --level 345 mysql on
四、修改mysql密码
在shell中执行
mysqladmin -u root password 'root123'
此处将密码设为root123,连接mysql,使用命令:
mysql -uroot -proot123
登录成功,密码修改成功。