yum -y install wgetwget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.37-linux-glibc2.12-x
yum -y install wgetwget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz -P /usr/local/src/tar xzf /usr/local/src/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz -C /usr/local/mv /usr/local/mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysqlyum -y install perluseradd mysql -M -s /sbin/nologinmkdir /datacd /usr/local/mysql/./scripts/mysql_install_db --user=mysql --datadir=/datacp support-files/mysql.server /etc/init.d/mysqld/bin/cp -f support-files/my-default.cnf /etc/my.cnfecho 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profileln -s /usr/local/mysql/lib/libmysqlclient.so.18 /lib64/
在上面的步骤中,我们把mysql的bin目录添加到环境变量中,要使其立即生效,可执行以下命令:
source /etc/profile
或者重新打开一个终端也可以。
安装完后修改一下配置文件,在[mysqld]下新增以下内容:
datadir = /datacharacter_set_server = utf8log-bin = mysql-bininnodb_file_per_table = 1lower_case_table_names = 1
其中第一条是必须的,其他可选。
日常管理常用命令:
# 启动/etc/init.d/mysqld start# 停止/etc/init.d/mysqld stop# 重启/etc/init.d/mysqld restart# 开机自动启动chkconfig mysqld on# 禁止开机自动启动chkconfig mysqld off
为root用户设置密码:
mysqladmin -u root password 'root'