wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz /usr/local/
cd /usr/local/
tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql
cd mysql
cd support-files/
cp my-default.cnf /etc/my.cnf
vi /etc/my.cnf
输入
[mysql]
default-character-set=utf8
[mysqld]
default-storage-engine=INNODB
character_set_server=utf8
拷贝mysql启动文件
cp mysql.server /etc/init.d/mysql
vi /etc/init.d/mysql
在对应位置添加
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
创建和mysql相关的用户和用户组
groupadd mysql
useradd -r -g mysql mysql
passwd mysql
chown -R mysql:mysql /usr/local/mysql/
usermod -d /home/mysql mysql
初始化数据库
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
根据初始日志记录,得到root@localhost的初始密码oEo&PI>hL46n
启动数据库
./mysqld_safe --user=mysql &
登录后修改root密码
./mysql -uroot -p
然后设置密码为chenli
set password=password('chenli');
grant all privileges on *.* to root@'%' identified by 'chenli';
grant all privileges on *.* to root@'192.168.1.98' identified by 'chenli';
flush privileges;
设置开机启动
chkconfig --add mysql
chkconfig mysql on
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'chenli' WITH GRANT OPTION;
GRANT ALL ON *.* TO 'root'@'%';
GRANT ALL ON *.* TO 'root'@'localhost';
GRANT ALL ON *.* TO 'root'@'127.0.0.1';
CREATE USER 'sa'@'%' IDENTIFIED BY 'chenli';
CREATE USER 'sa'@'localhost' IDENTIFIED BY 'chenli';
CREATE USER 'sa'@'127.0.0.1' IDENTIFIED BY 'chenli';
GRANT ALL ON *.* TO 'sa'@'%';
GRANT ALL ON *.* TO 'sa'@'localhost';
GRANT ALL ON *.* TO 'sa'@'127.0.0.1';
mv mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz /usr/local/
cd /usr/local/
tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql
cd mysql
cd support-files/
cp my-default.cnf /etc/my.cnf
vi /etc/my.cnf
输入
[mysql]
default-character-set=utf8
[mysqld]
default-storage-engine=INNODB
character_set_server=utf8
拷贝mysql启动文件
cp mysql.server /etc/init.d/mysql
vi /etc/init.d/mysql
在对应位置添加
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
创建和mysql相关的用户和用户组
groupadd mysql
useradd -r -g mysql mysql
passwd mysql
chown -R mysql:mysql /usr/local/mysql/
usermod -d /home/mysql mysql
初始化数据库
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
根据初始日志记录,得到root@localhost的初始密码oEo&PI>hL46n
启动数据库
./mysqld_safe --user=mysql &
登录后修改root密码
./mysql -uroot -p
然后设置密码为chenli
set password=password('chenli');
grant all privileges on *.* to root@'%' identified by 'chenli';
grant all privileges on *.* to root@'192.168.1.98' identified by 'chenli';
flush privileges;
设置开机启动
chkconfig --add mysql
chkconfig mysql on
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'chenli' WITH GRANT OPTION;
GRANT ALL ON *.* TO 'root'@'%';
GRANT ALL ON *.* TO 'root'@'localhost';
GRANT ALL ON *.* TO 'root'@'127.0.0.1';
CREATE USER 'sa'@'%' IDENTIFIED BY 'chenli';
CREATE USER 'sa'@'localhost' IDENTIFIED BY 'chenli';
CREATE USER 'sa'@'127.0.0.1' IDENTIFIED BY 'chenli';
GRANT ALL ON *.* TO 'sa'@'%';
GRANT ALL ON *.* TO 'sa'@'localhost';
GRANT ALL ON *.* TO 'sa'@'127.0.0.1';