1:下载mysql5.7安装包
wget http://dev.MySQL.com/get/Downloads/MySQL-5.7/mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz
2:解压复制
tar -xvf mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz mv mysql-5.7.11-Linux-glibc2.5-x86_64/* /usr/local/mysql/
3:创建data
mkdir /usr/local/mysql/data
4:创建用户和权限
groupadd mysql useradd -g mysql mysql chown -R mysql.mysql /usr/local/mysql/
5:初始化
./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
6:复制配置文件
cp -a ./support-files/my-default.cnf /etc/my.cnf
7:增加免密登陆
vi /etc/my.cnf
修改my.cnf文件 # These are commonly set, remove the # and set as required. basedir = /usr/local/mysql datadir = /usr/local/mysql/data port = 3306 # server_id = ..... socket = /tmp/mysql.sock character-set-server = utf8 # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M
末尾增加
skip-grant-tables
8:mysql服务放到系统服务中
cp -a ./support-files/mysql.server /etc/init.d/mysqld
9:启动
service mysqld start
10:修改mysql密码
[root@localhost mysql]# mysql -u root mysql mysql>update user set authentication_string=PASSWORD('你的密码') where user='root';