废话少说:
一.准备工作:
1.添加mysql用户组
groupadd mysql
2.添加mysql用户
useradd -g mysql mysql
-g 指定用户组
二.正文:
1.下载mysql glibc版 http://dev.mysql.com/downloads/mysql/
选择Linux-Generic 64位tar.gz版本
linux用户 : wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
2.解压mysql 并移动到usr/local/下
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
创建data文件夹
mkdir data
3.改变文件夹所有者
chown -R mysql /usr/local/mysql
chgrp -R mysql /usr/local/mysql
4.安装mysql
cd /usr/local/mysql #进入安装目录
cd ../bin
./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
[WARNING] mysql_install_dbisdeprecated. Please consider switchingtomysqld --initialize 2015-11-10 02:09:23
[WARNING] The bootstrap log isn't empty: 2015-11-10 02:09:23
[WARNING] 2015-11-10T10:09:18.114182Z 0
[Warning] --bootstrap is deprecated. Please consider using --initialize instead 2015-11-10T10:09:18.129343Z 0
[Warning] Changed limits: max_open_files: 1024 (requested 5000) 2015-11-10T10:09:18.129408Z 0
[Warning] Changed limits: table_open_cache: 431 (requested 2000)
mysql5.7新特性:由上面可以看出, mysql_install_db 已经不再推荐使用了,建议改成 mysqld --initialize 完成实例初始化
./mysqld --user=mysql--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
[Warning] TIMESTAMPwithimplicit DEFAULTvalueis deprecated. Please use--explicit_defaults_for_timestamp server option (see documentation for more details). 2016-04-08T01:47:59.945537Z 0
[Warning] InnoDB: New log files created, LSN=45790 2016-04-08T01:48:00.333528Z 0 [Warning] InnoDB: Creatingforeignkeyconstraint system tables. 2016-04-08T01:48:00.434908Z 0
[Warning] Noexisting UUID has been found, so we assume that thisis the firsttimethat this server has been started. Generating a new UUID: ece26421-fd2b-11e5-a1e3-00163e001e5c. 2016-04-08T01:48:00.440125Z 0
[Warning] Gtid table is not ready tobe used.Table 'mysql.gtid_executed'cannot be opened. 2016-04-08T01:48:00.440904Z 1
[Note] A temporarypasswordis generated forroot@localhost:**mjT,#x_5sW
产生一个临时的密码,登录mysql的时候需要用到。
5.测试安装
cd /usr/lcoal/mysql/support-files
./mysql.server start
显示 start Starting MySQL.. OK!说明成功
6.设置mysql启动初始化文件
cd /usr/local/mysql/support-files
cp my-default.cnf /etc/my.cnf
配置my.cnf
vim /etc/my.cnf
For advice on how to change settings please see
http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
*** DO NOT EDIT THIS FILE. It's a template which will be copied to the
*** default location during install, and will be replaced if you
*** upgrade to a newer version of MySQL.
[mysqld]
Remove leading # and set to the amount of RAM for the most important data
cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 128M
Remove leading # to turn on a very important data integrity option: logging
changes to the binary log between backups.
log_bin
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
pid-file = /usr/local/mysql/mysql.pid
max_connections = 1500
read_buffer_size = 2M
character_set_server=utf8
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
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
[client]
default-character-set=utf8
7.设置mysql开机自启动
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld/
chmod 755 /etc/init.d/mysqld # 增加执行权限
chkconfig --list mysqld # 检查自启动项列表中没有mysqld这个,
chkconfig --add mysqld # 如果没有就添加mysqld:
chkconfig mysqld on # 用这个命令设置开机启动:
至此mysql全部安装完毕
运行命令:service mysqld start 启动mysql
./usr/local/mysql/bin/mysql -uroot -p
PASSWORD: **mjT,#x_5sW
输入刚产生的临时密码
修改 root 密码 set password for 'root'@'localhost' = '你的密码'
ok!
网友评论