mysql5.6.35 二进制快速安装
2017-05-25 11:59
295 查看
说明:
mysql安装在/data/mysql-5.6.35目录下;
如果安装在/usr/local/mysql/目录下,则两个sed不许执行,因为默认是/usr/local/目录下;
wget https://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
tar -zxf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.35-linux-glibc2.5-x86_64 /data/mysql-5.6.35
mkdir -pv /data/mysql-5.6.35/{var,log}
touch /data/mysql-5.6.35/log/error.log
sudo chown -R mysql:mysql /data/mysql-5.6.35/
export PATH=/data/mysql-5.6.35/bin:$PATH
source ~/.bash_profile
sudo ./scripts/mysql_install_db --basedir=/data/mysql-5.6.35/ --datadir=/data/mysql-5.6.35/data/ --user=mysql
sudo sed -i 's#/usr/local/mysql#/data/mysql-5.6.35#g' /data/mysql-5.6.35/bin/mysqld_safe
sudo sed -i 's#/usr/local/mysql#/data/mysql-5.6.35#g' /data/mysql-5.6.35/support-files/mysql.server
sudo ln -s /data/mysql-5.6.35/bin/mysql /usr/bin
sudo vim /data/mysql-5.6.35/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
server-id = 1
port = 3306
basedir = /data/mysql-5.6.35
datadir = /data/mysql-5.6.35/data
socket = /tmp/mysql.sock
binlog-ignore-db = mysql
log-bin = /data/mysql-5.6.35/log/mysql-bin
innodb_file_per_table = 1
open_files_limit = 65535
sql_mode =NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
skip-host-cache
skip-name-resolve
max_connections = 1024
wait_timeout = 31536000
interactive_timeout = 31536000
character-set-server =utf8mb4
collation-server = utf8mb4_general_ci
init_connect = 'SET NAMES utf8mb4'
lower_case_table_names = 1
log_error = /data/mysql-5.6.35/log/error.log
slow_query_log = 1
slow_query_log_file = /data/mysql-5.6.35/log/slow.log
[mysqld_safe]
err-log= /data/mysql-5.6.35/log/mysqld_safe_err.log
pid-file = /data/mysql-5.6.35/var/mysqld.pid
sudo chkconfig mysqld on
sudo chkconfig --list mysqld
ps –ef | grepmysql
mysql安装在/data/mysql-5.6.35目录下;
如果安装在/usr/local/mysql/目录下,则两个sed不许执行,因为默认是/usr/local/目录下;
1. 下载
cd /data/wget https://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
tar -zxf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.35-linux-glibc2.5-x86_64 /data/mysql-5.6.35
2. 新建mysql用户及设置权限
sudo useradd -s /sbin/nologin -M mysqlmkdir -pv /data/mysql-5.6.35/{var,log}
touch /data/mysql-5.6.35/log/error.log
sudo chown -R mysql:mysql /data/mysql-5.6.35/
3. 添加环境变量:
vim ~/.bash_profileexport PATH=/data/mysql-5.6.35/bin:$PATH
source ~/.bash_profile
4. 初始化数据库,修改默认路径
cd /data/mysql-5.6.35/sudo ./scripts/mysql_install_db --basedir=/data/mysql-5.6.35/ --datadir=/data/mysql-5.6.35/data/ --user=mysql
sudo sed -i 's#/usr/local/mysql#/data/mysql-5.6.35#g' /data/mysql-5.6.35/bin/mysqld_safe
sudo sed -i 's#/usr/local/mysql#/data/mysql-5.6.35#g' /data/mysql-5.6.35/support-files/mysql.server
sudo ln -s /data/mysql-5.6.35/bin/mysql /usr/bin
5. 修改配置文件
sudo rm –f /etc/my.cnfsudo vim /data/mysql-5.6.35/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
server-id = 1
port = 3306
basedir = /data/mysql-5.6.35
datadir = /data/mysql-5.6.35/data
socket = /tmp/mysql.sock
binlog-ignore-db = mysql
log-bin = /data/mysql-5.6.35/log/mysql-bin
innodb_file_per_table = 1
open_files_limit = 65535
sql_mode =NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
skip-host-cache
skip-name-resolve
max_connections = 1024
wait_timeout = 31536000
interactive_timeout = 31536000
character-set-server =utf8mb4
collation-server = utf8mb4_general_ci
init_connect = 'SET NAMES utf8mb4'
lower_case_table_names = 1
log_error = /data/mysql-5.6.35/log/error.log
slow_query_log = 1
slow_query_log_file = /data/mysql-5.6.35/log/slow.log
[mysqld_safe]
err-log= /data/mysql-5.6.35/log/mysqld_safe_err.log
pid-file = /data/mysql-5.6.35/var/mysqld.pid
6. 将服务脚本复制到/etc/init.d目录下,并添加到服务列表
sudo cp support-files/mysql.server /etc/init.d/mysqld7. 开机自启动
sudo chkconfig --add mysqldsudo chkconfig mysqld on
sudo chkconfig --list mysqld
8. 启动mysql
sudo /etc/init.d/mysqld startps –ef | grepmysql
9. 设置mysql密码
sudo /data/mysql-5.6.35/bin/mysqladmin -u root password 'newpassword'10. 登录
mysql -uroot -p11. 配置安全策略:
[root@KVM mysql-5.6.35]#sudo /data/mysql-5.6.35/bin/mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the currentpassword for the root user. Ifyou've just installed MySQL, andyou haven't set the root password yet, the password will be blank,so you should just press enter here. Enter current password for root (enter for none):OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQLroot user without the proper authorisation. You already have a root password set, so you can safely answer 'n'. Change the root password? [Y/n] n ... skipping. By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem. This is intended only fortesting, and to make the installationgo a bit smoother. You shouldremove them before moving into aproduction environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] n ... Success! By default, MySQL comes with a database named 'test' that anyone canaccess. This is also intended only fortesting, and should be removedbefore moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on testdatabase... ... Success! Reloading the privilege tables will ensure that all changes made so farwill take effect immediately. Reload privilege tables now? [Y/n] y ... Success! All done! If you've completed allof the above steps, your MySQLinstallation should now be secure. Thanks for using MySQL! Cleaning up...[root@KVM mysql-5.6.35]#相关文章推荐
- mysql5.6.35 二进制快速安装
- mysql二进制版本的安装
- 在linux中二进制mysql的安装
- CentOS 5.3上用yum快速安装Apache+php+Mysql+phpMyAdmin
- 快速安装mysql
- 使用二进制的方式安装mysql实践纪要
- Linux+Apache+PHP+Mysql快速安装
- 二进制编译安装mysql
- MySQL二进制方式安装
- mysql二进制安装过程
- Fedora 13下Apache,MySQL,PHP二进制编译安装
- CentOS 5.5 编译安装apache+php+mysql,利用CMS快速建立论坛
- Mysql快速安装与基本配置
- linux下快速安装apache+php+mysql
- FreeBSD+Apache+PHP+Mysql快速安装
- FreeBSD+Apache+PHP+Mysql快速安装
- mysql的三种安装方式:RPM 二进制包和源代码
- VPS 快速安装 Linux+Nginx+MySQL+PHP 环境
- 二进制--安装mysql
- window XP安装 apache 2.2.19 + 要下载二进制的php5.3.6 + Mysql 5.5配置(彻底解决 Fatal error: Class 'mysqli' not found in )