centos7下安装mysql5.7
去这看
在linux(centos)下有2种方式安装,第一种使用rpm安装在网上可以搜到,第二种使用压缩包方式,我这里是采用压缩包方式。
1.这里我将mysql安装在/usr/local/mysql目录里面,也可以安装在其他地方
mkdir /usr/local/mysql
2.下载mysql压缩包
- wget http://dev.MySQL.com/get/Downloads/MySQL-5.7/mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz
- 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/
- mkdir /usr/local/mysql/data
- groupadd mysql
- chown -R mysql.mysql /usr/local/mysql/
- [root@localhost mysql] ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
- 2016-01-20 02:47:35 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
- 2016-01-20 02:47:45 [WARNING] The bootstrap log isn't empty:
- 2016-01-20 02:47:45 [WARNING] 2016-01-19T18:47:36.732678Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
- 2016-01-19T18:47:36.750527Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
- 2016-01-19T18:47:36.750560Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
7. 复制配置文件到 /etc/my.cnf
- cp -a ./support-files/my-default.cnf /etc/my.cnf (选择y)
- cp -a ./support-files/mysql.server /etc/init.d/mysqld
- 修改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
9.启动mysql
- service mysqld start
10.修改mysql密码
- [root@localhost mysql]# mysql -u root mysql
- mysql>update user set authentication_string=PASSWORD('你的密码') where user='root';
10.创建快捷方式