编译安装perl(可以用已下载的压缩包安装)
可先、安装cmake,cmake编译安装
1、安装mysql5.5,mysql5.6安装
http://dev.mysql.com/doc/refman/5.5/en/binary-installation.html
解压mysql到usr/local/webserver/下
#groupadd mysql 添加用户组
#useradd -r -g mysql mysql 添加用户
#mkdir -p /usr/local/webserver/mysql 创建安装目录
#mkdir -p /data/mysql/data 创建数据库目录
# chown mysql:mysql /data/mysql/ #目录权限修改
#tar -zxvf mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz
#mv mysql-5.6.10-linux-glibc2.5-x86_64/* /usr/local/webserver/mysql
#rm -rf ./mysql-5.6.10-linux-glibc2.5-x86_64/
#cd /usr/local/webserver/
#ln -s full-path-to-mysql-VERSION-OS mysql
#cd mysql
chown -R mysql .
chgrp -R mysql .
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/webserver/mysql --datadir=/data/mysql/data # MySQL 5.7.6之前版本
./bin/mysqld --initialize --user=mysql --datadir=/data/mysql/data --basedir=/usr/local/webserver/mysql-5.7.11 # MySQL 5.7.6 之后版本使用 其实在执行 mysqld --initialize 后系统就会为 root 生成一个初始化密码,并在屏幕标准输出时显示出来,这个要记住!用这个密码第一次登录后,才能再修改密码,这里假定系统生成的初始化密码为 xxxxxx,命令如下:# bin/mysql --user=root --password=xxxxxx
bin/mysql_ssl_rsa_setup --datadir=/data/mysql/data# MySQL 5.7.6之后版本使用
cp support-files/my-medium.cnf /usr/local/webserver/mysql/my.cnf
下面的启动方式换成后面“注:”的方式
bin/mysqld_safe --user=mysql &
cp support-files/mysql.server /etc/init.d/mysql.server
2、安装mysql5.7安装
http://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /root/webserver/mysql-VERSION-OS.tar.gz -C /usr/local/webserver/mysql
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> mkdir mysql-files
shell> chmod 750 mysql-files
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql # Before MySQL 5.7.6
shell> bin/mysqld --initialize --user=mysql --datadir=/data/mysql/data --basedir=/usr/local/webserver/mysql-5.7.11 # MySQL 5.7.6 and up
shell> bin/mysql_ssl_rsa_setup # MySQL 5.7.6 and up
shell> chown -R root .
shell> chown -R mysql data mysql-files
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
注:安装完后如果启动出现
vi ./support-files/mysql.server
配置:
basedir=/usr/local/webserver/mysql
datadir=/data/mysql/data
启动mysql
./support-files/mysql.server start
启动错误的话:出现
Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/917.pid).
support-files/mysql.server
解决参考:http://blog.csdn.net/zalion/article/details/9274263
解决1、:rm -rf /etc/my.cnf
这样默认的my.cnf变成/usr/local/webserver/mysql/my.cnf
解决2、并且修改/data/mysql/的目录权限为mysql #chown mysql:mysql /data/mysql/
配置my.cnf可复制git上的my.cnf
解决3、pid路径的修改要先停止mysql运行,在修改,否则mysql无法关闭。
解决4、去mysql的数据目录/data看看,如果存在mysql-bin.index,就赶快把它删除掉吧,它就是罪魁祸首了。本人就是使用第三条方法解决的 !
解决5、my.cnf中的pid_file改成pid-file
2、保证所有数据库目录、log目录、安装目录都是mysql mysql权限
3、修改vi ./ support-files/ mysql.server中的basedir到指定目录
basedir=/usr/local/webserver/mysql
4、修改my.cnf中的basedir等配置放到[mysqld]下不能放在[mysqld_safe]否则mysql.server restart会出错
5、修改环境变量
vi /etc/profile
末尾加入:
export PATH="$PATH:/usr/local/ webserver/mysql/bin:/usr/local/webserver/mysql/support-files"
source /etc/profile 立即生效
6、mysql局域网访问mysql
mysql -u root -p登录
use mysql;
select user,Host,Password from user;
update user set Host='%' where Host='192.168.1.2';
之后退出重启mysql %为所有用户sql
设置ip白名单:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.1.xxx.xx' IDENTIFIED BY 'gxxxxxx' WITH GRANT OPTION;//root用户 密码gxxxxxx
flush privileges; #生效
a、my.cnf查找my.cnf位置
./bin/mysql --help | grep my.cnf
b、mysql密码错误,mysql登录密码:http://jingyan.baidu.com/article/3ea51489e6cfbe52e61bba25.html
错误:ERROR 1045 (28000): Access denied for user
my.cnf中配置skip-grant-tables后重启;此为路过密码验证;修改密码后删除;
MySQL 5.7密码字段password修改authentication_string
mysql修改密码,mysql密码修改
http://www.myhack58.com/Article/sort099/sort0102/2015/60511.htm
mysql> update mysql.user set authentication_string=password('gb5528877'),Host='192.168.1.4' where user='root' and Host='917';
update user set Password=password('ggD-6528877') where user='root' and Host IN('127.0.0.1','localhost');
#更改密码为 'gbxxxxxxx'
mysql>flush privileges; #更新权限
c、局域网访问mysql局域网访问配置
进入msyql修改
use msyql;
select user,Host,Password from user;
update user set Host='%' where host='::1';
指定ip能够访问的话
update user set Host='192.168.1.4' where host='::1';
设置ip白名单:添加一个用户
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.114' IDENTIFIED BY 'gxxxxx' WITH GRANT OPTION;//root用户 密码gxxxxx
flush privileges; 刷新缓存,用户生效
之后重启mysql就可以连接数据库了
如果不行:配置防火墙,开放3306端口;IP自行修改;
# iptables -A INPUT -s 127.0.0.1 -p tcp --dport 3306 -j ACCEPT;
iptables -A INPUT -s 192.168.1.4 -p tcp --dport 3306 -j ACCEPT;
iptables -A INPUT -s 192.168.1.114/116 -p tcp --dport 3306 -j ACCEPT;
#/etc/rc.d/init.d/iptables save 保存配置
#service iptables restart 重启防火墙