首页 > 代码库 > CentOS7安装mysql
CentOS7安装mysql
6. 安装mysql
# 配置环境变量,并立即更新
vi /etc/profile
export MYSQL_HOME="/usr/local/mysql"
export PATH="$PATH:$MYSQL_HOME/bin"
source /etc/profile
wget http://120.52.72.24/cdn.mysql.com/c3pr90ntc0td//Downloads/MySQL-5.7/mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz -O /usr/local/src #glibc是编译过后的版本,不需要make install
cd /usr/local/src
tar -zxvf mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
mv /usr/local/src/mysql-5.7.16-linux-glibc2.5-x86_64 $MYSQL_HOME
chown -R mysql:mysql $MYSQL_HOME #更改$MYSQL_HOME权限为mysql:mysql
groupadd mysql #添加用户组mysql
useradd -r -g mysql mysql -d $MYSQL_HOME #添加用户mysql,指定其用户组是mysql,home路径是$MYSQL_HOME
passwd mysql #设置mysql用户的登陆密码
yum install -y perl-Module-Install.noarch
$MYSQL_HOME/bin/mysqld --initialize --explicit_defaults_for_timestamp --user=mysql --basedir=$MYSQL_HOME --datadir=$MYSQL_HOME/data #第一次启动
2016-12-08T05:12:08.916945Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-12-08T05:12:08.993901Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-12-08T05:12:09.048289Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: de6b7880-bd04-11e6-8efb-080027798ca2.
2016-12-08T05:12:09.048994Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
2016-12-08T05:12:09.049893Z 1 [Note] A temporary password is generated for root@localhost: 0w=a_KV.gT_k
cp $MYSQL_HOME/support-files /etc/my.cnf #mysql服务启动配置文件
cp $MYSQL_HOME/support-files/mysql.server /etc/init.d/mysql #将mysql加入到可控制启动的服务的文件夹内,并命名mysql,即service可控制的服务名,至此可用service mysql start控制启动mysql
chkconfig --add mysql
chkconfig mysql on
service mysql start
mysql -u root -p
输入密码:0w=a_KV.gT_k
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘123456‘; #第一次改密码为‘123456‘
mysqladmin -uroot -p123456 password ‘123‘ #第二次及以后改密码
本文出自 “12382059” 博客,请务必保留此出处http://12392059.blog.51cto.com/12382059/1880864
CentOS7安装mysql