1. 下载MySQL安装包
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.62.tar.gz
2. 解压缩MySQL安装包
tar -zxvf mysql-5.5.62.tar.gz
3. 创建MySQL用户和用户组
groupadd mysql useradd -r -g mysql -s /bin/false mysql
4. 安装MySQL
cd mysql-5.5.62 cmake . make make install
5. 创建MySQL配置文件
vi /etc/my.cnf
输入以下内容:
[mysql] default-character-set=utf8 [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql character-set-server=utf8 collation-server=utf8_general_ci bind-address=0.0.0.0
6. 初始化MySQL
cd /usr/local/mysql ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/var/lib/mysql
7. 启动MySQL
cd /usr/local/mysql ./bin/mysqld_safe --user=mysql &
8. 设置MySQL启动项
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql chmod +x /etc/init.d/mysql
9. 启动MySQL
service mysql start
到这里,MySQL安装和配置就完成了。希望这篇文章对您有所帮助。