安裝Mysql5.7
將mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz 拷貝到/soft下
創(chuàng)建組和不可登錄用戶
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
依賴安裝 (可能需要)
yum -y install libaio libaio-devel
解壓安裝
tar -zxvf mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.16-linux-glibc2.5-x86_64 /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
mkdir /usr/local/mysql/data
chown -R root /usr/local/mysql
chown -R mysql /usr/local/mysql/data
修改配置文件
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
vim /etc/my.cnf
[mysql]
default-character-set=utf8[mysqld]
character_set_server=utf8basedir = /usr/local/mysql/
datadir = /usr/local/mysql/data
socket = /tmp/mysql.sock
- 修改環(huán)境變量
vi /etc/profile
MYSQL_HOME=/usr/local/mysql
PATH=$MYSQL_HOME/bin:$PATH
export MYSQL_HOME PATH
source /etc/profile
初始化數(shù)據(jù)庫
cd /usr/local/mysql
這里會有一個隨機密碼,請記牢
mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
制作啟動文件
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chkconfig --add mysql
chkconfig mysql on
vi /etc/init.d/mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
- 啟動停止服務(wù)
service mysql start
mysql -uroot -p
進入后必須更改密碼,否則不允許操作
SET PASSWORD = PASSWORD('newpasswd');
service mysql stop