赞
踩
- #安装wget
- yum -y install wget vim bash-completion
-
- #安装cmake、gcc、gcc-c++等
- yum -y install gcc gcc-c++ cmake ncurses-devel autoconf perl perl-devel
wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.40.tar.gz
mkdir -p /usr/local/mysql/data
- #解压命令
- tar -zxvf mysql-5.6.40.tar.gz
-
- #进入解压后的文件夹
- cd mysql-5.6.40
-
- #编译
- cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
- -DINSTALL_DATADIR=/usr/local/mysql/data \
- -DDEFAULT_CHARSET=utf8 \
- -DDEFAULT_COLLATION=utf8_general_ci \
- -DEXTRA_CHARSETS=all \
- -DENABLED_LOCAL_INFILE=1
-
- #安装
- make && make install
- cd /usr/local/mysql
-
- cp support-files/my-default.cnf /etc/my.cnf
- cd /usr/local/mysql
-
- ./scripts/mysql_install_db --user=mysql
- vim /etc/profile
-
- export MYSQL_HOME="/usr/local/mysql"
- export PATH="$PATH:$MYSQL_HOME/bin"
-
- source /etc/profile
- [root@localhost ~]# cat /etc/my.cnf
- [mysqld]
- basedir = /usr/local/mysql
- datadir = /usr/local/mysql/data
- port = 3306
- # server_id = .....
- socket = /tmp/mysql.sock
-
- sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
- [mysql]
- # 设置mysql客户端默认字符集
- default-character-set=utf8mb4
- socket=/var/lib/mysql/mysql.sock
- [mysqld]
- skip-name-resolve
- #设置3306端口
- port = 3306
- socket=/var/lib/mysql/mysql.sock
- # 设置mysql的安装目录
- basedir=/usr/local/mysql
- # 设置mysql数据库的数据的存放目录
- datadir=/usr/local/mysql/data
- # 允许最大连接数
- max_connections=200
- # 服务端使用的字符集及字符校验方式
- character_set_server=utf8mb4
- collation_server=utf8mb4_general_ci
- # 创建新表时将使用的默认存储引擎
- default-storage-engine=INNODB
- lower_case_table_name=1
- max_allowed_packet=16M
- cd /usr/local/mysql/
- cp support-files/mysql.server /etc/init.d/mysql
- #启动mysql服务
- service mysql start
-
- #重启mysql服务
- service mysql restart
-
- #停止mysql服务
- service mysql stop
-
- #将服务添加到开机启动指令管理的服务列表中
- chkconfig --add mysql
-
- #开机自启
- chkconfig mysql on
chown -R mysql:mysql /var/lib/mysql
mysqladmin -u root password
- #防火墙关闭或开启3306端口
- #0.0 禁止防火墙开机自启
- systemctl disable firewalld
- #0.1 关闭防火墙
- systemctl stop firewalld
-
- #1.0 开启端口3306
- firewall-cmd --zone=public --add-port=3306/tcp --permanent
- #1.1 重启防火墙
- firewall-cmd --reload
- #1.2 查看已经开放的端口
- firewall-cmd --list-ports
-
-
- #开启远程访问
- #2.0 创建一个可远程访问的root用户
- GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";
- #2.1 指定远程登录root用户时使用的密码
- GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '远程登录root用户的密码' WITH GRANT OPTION;
- #2.2 刷新
- flush PRIVILEGES;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。